Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Site caching file, need this to stop

I have a script that generates a new CSV file (in my web directory) every half hour, it replaces the original one and puts a new one in its place with the same file name, the file is linked to on my website.

When I download the file from my website, instead of getting an updated version I get a file that is the same as the first time I downloaded it on this computer.

My first thought was to make sure that the script is still running properly and after testing, I can confirm that it is.

I then cleared the cache and download history in Chrome and tried to download it again, this time it worked as intended.

I am running this off of a rackspace cloud server running ubuntu and apache. I assume there is some setting that I need to reconfigure to fix this problem. Could someone please point me in the right direction.

Thanks in advance.

like image 485
jimstandard Avatar asked Oct 10 '11 21:10

jimstandard


People also ask

How do I stop a site from caching?

When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache.

How do I stop CloudFront caching?

On your custom origin web server application, add Cache-Control no-cache, no-store, or private directives to the objects that you don't want CloudFront to cache. Or, add Expires directives to the objects that you don't want CloudFront to cache.


1 Answers

A somewhat dirty solution is to append to the script that let you download the file a random number (or maybe the timestamp) as parameter to prevent the caching.

For example:

www.example.com/download.php?file=my.csv&rand=123456789

like image 76
Aurelio De Rosa Avatar answered Sep 26 '22 06:09

Aurelio De Rosa