I have a website that because of an ill-prepared apache conf file has instructed users to cache a website URL several years into the future. As a result, when a person visit
Years late, but it might help someone down the road: if you've got any javascript file that isn't cached years into the future (i.e. if you have any way of running new js on the cached site), add some js that will programatically clear the cache. Once the configuration is fixed and/or the update complete, remove the cache clearing js.
Ctrl + F5 in jquery to clear browser cache
Use different URLs. If the main entry point to your website (like the main index file) is cached, then you're screwed... maybe you should register another domain name?
I think that there is no way of doing this. If they never contact your sever there really is nothing you can do about it.
It is arguable that if your "major update" is just in a few (2 or 3) weeks, you only need to reconfigure your apache conf now (no far future stuff for html - only for assets and content that will most likely never change). The Firefox cache is ~50MB by default and that is not much because images get also cached and modern websites have a lot of content.
Not perfect - but thats what I would do - when I don't want to or can't change the URL's ;)
You can make all the necessary changes inside the HTML files, like
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
But also, you can explicitely tell Apache to use mod_expires.c module, and add a couple of directives to httpd.conf file:
<IfModule mod_expires.c>
# Turn on the module.
ExpiresActive on
# Set the default expiry times.
ExpiresByType text/html "modification plus 5 seconds"
ExpiresByType text/javascript "modification plus 5 seconds"
ExpiresDefault "access plus 2 days"
</IfModule>
This way you add the http headers cache-control and expires, to responses, in order for thw browser to update the cache 5 seconds after the file was modified in the origin, for those kinds of files, and 2 days after being accessed by the browser for all the other kinds of files.
Hope this helps.
The browsers are using the cache for optimizing calls to the servers, in the case of any update of your build production you have to force browser to refresh resources from the server just like use f5 to clear the cache.
The solution for that you should add some parameters to your meta-includes (URLs) by the way the browser will not find the resources in the cache with such parameter so it will refresh them from the server.
You can parameter your includes per version for example like the below :
<script src="assets/js/customscript.js?v=1.1"></script>
<link rel="stylesheet" type="text/css" href="assets/style/main.css?v=1.1"></link>