Skip to content
Advertisement

Avoid Chrome saving .txt and .php files to cache

I am developing a web page (2075.mooo.com, (it is in Catalan)) where teachers control students’ arrivals with an NFC card in an Arduino.

The thing is that I save students’ data on .txt files, but Chrome saves those to its cache, and I have to constantly remove the cache files. Is there a way to not let Chrome do that or use another strategy instead of .txt files? Because I cannot say to all teachers and students to remove their chrome cache.

Thanks.

Advertisement

Answer

If using Apache:

Add this to a .htaccess file created in the directory you save the .txt files:

Header always set Pragma "no-cache"
Header always set Cache-Control "no-store, must-revalidate"
Header always set Expires "0"

OR

If you have access to httpd.conf, you can add the following to it:

<LocationMatch ".*.txt">
     Header always set Pragma "no-cache"
     Header always set Cache-Control "no-store, must-revalidate"
     Header always set Expires "0"
</LocationMatch>

They must clear the cache that they already have in their browser.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement