Cache problem?

I have very simple website (http://egads.epizy.com/index.php) that shows the contents of two files: heimdall_clock.txt and heimdall_message.txt.

This works fine, now with setInterval I would like read the file again after 5 seconds and show its new content. If I copy a new file from via ftp the page does not see the change unless in my browser I press F12, go to the “Network” tab and check “Disable cache”.

How can I force it to really take what it is in the file? I have tried many variations in php, html and changing .htaccess but nothing worked.

I’d greatly appreciate your help!

You should be able to forcefully disable cache through .htaccess rules. And I just checked your website, and my browser loads a fresh copy of the file on every request without any cache. So, as far as I can see, your current settings work as intended.

Please note that browser cache works by downloading the file from the server once, and then not asking the server again until the local cache expires. So if a browser first downloads and caches a copy, and then you disable caching in the server, the browser won’t know the new caching settings until it asks the server. And the browser will only ask when the local cache has expired. This is why the new caching settings may not have shown any effects right away.

1 Like

Hi, thank you very much for checking. It looks like I had several issues. One being the .htaccess and another my browser. For the record, I will add my .htaccess here:

# DISABLE CACHING
<IfModule mod_headers.c>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
</IfModule>

<FilesMatch "\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|mp3|mp4|png|pdf|swf|txt)$">
    <IfModule mod_expires.c>
        ExpiresActive Off
    </IfModule>
    <IfModule mod_headers.c>
        FileETag None
        Header unset ETag
        Header unset Pragma
        Header unset Cache-Control
        Header unset Last-Modified
        Header set Pragma "no-cache"
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
    </IfModule>
</FilesMatch>

Thank you very much again!

It looks like the code does not show up as it should. Sorry.

1 Like

I’m sorry, but what is the current status? Does your cache work or not? And did you validate it with a clean browser to make sure no old cache from before the new caching settings was being used?

2 Likes

Yes, it works with the .htaccess above and a clean browser. Thanks again.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.