Csv file export without full list

I have a server action

  • step1
    creates a query to detect all the records of a table present in the database
  • step2
    sets an Export CSV file
  • step3
    sets a File Download

In a php page I set a download and a button to download the CSV file

The download works, but after a first time the CSV file does not list all the records.
I can download a complete file only if I clear the browser cache

Does anyone know how to fix this

Thanks