Ajax cache control
        Posted  
        
            by Brian
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Brian
        
        
        
        Published on 2010-05-10T17:53:33Z
        Indexed on 
            2010/05/10
            18:14 UTC
        
        
        Read the original article
        Hit count: 577
        
Hello,
I am having a problem with ajax requests in Internet Explorer and in Chrome - I cannot bust the cache. Normal pages don't have the problem - it's just the ajax requests.
I know that one workaround is to append a random query string variable to the end of the URL. However, I don't want to lose all the benefits of caching, I just want the browser to pick up the new file if the version on the server is different from the cached version.
I have tried manually setting the ajax POST header, to no avail:
xmlHttp.setRequestHeader("Cache-Control", "must-revalidate");
Adding this to my .htaccess file doesn't work either:
<FilesMatch "\.(js|css).*">
Header set Cache-Control: "max-age=172800, public, must-revalidate"
</FilesMatch>
Any help would be greatly appreciated.
Thanks, Brian
© Stack Overflow or respective owner