Search code examples
html.htaccessgoogle-chromecachingbrowser-cache

chrome has cached html file that no longer exists on server


There was a static site with no cache control: site.com/index.html

now there is: site.com/index.php (index.html is deleted)

On chrome (where the old website has been opened before) chrome shows cached version index.html

Seems chrome loads the site without contacting the server

.htaccess

   <FilesMatch ".(css|html|swf)$">
       Header unset Cache-Control
   </FilesMatch>

any other .htaccess variations on cache busting do not work because chrome doesn`t seem to contact the server


Solution

  • That's normal behavior because you told Chrome before that it can cache your file. So it has no reason to ask the server because it already knows your file was not updated (which you know is wrong but you can't tell the browser).

    You have to delete the cache in your browser. The same effect will happen with all current browsers.

    If the old and new index page both include a JavaScript which is not cached you could use the script to trigger a redirect to index.PHP or a subpath

    To find out when the cached files will expire you might want to try ChromeCacheView and its teammates for Internet Explorer and Firefox, this will give you an impression when the cached files expire on your machine. After that you will know how long it is probably going to take until all your customers get the new version without purging their caches.

    Chrome Cache View showing expiration time