I have an issue where I update my server but I have to manually delete my browser cache in order to see my new changes.
Is there a way to make this automatic? I see a "noCache" variable that looks to be what I should set somehow?
I tried adding "?noCache=true" as a suffix to the web page just to test but that didn't seem to work.
Could someone please point me in the right direction on how to do this automatically for the user?
Thanks
1 decade ago
by Joncom
One trick, if you can use something like PHP, is to add a timestamp to the URL of whatever you load. For example, url/image.png?time=1
is not the same thing as url/image.png?time=2
and the browser will reload the image each time so long as the value of time changes.
It looks like Impact adds a current time suffix when it loads. For example:
this.data.src = window.ig.prefix + this.path + window.ig.nocache;
Isn't this code supposed to trick the browser into grabbing new content from the server similar to how you describe?
1 decade ago
by dominic
If you append
?nocache
to your game&
039;s URL the #ig.nocache
variable will be automatically set to a random string. E.g.:
http://example.com/impact-game/?nocache
Thanks Guys,
So, if I understand correctly, this is what I need to do:
For example, the user goes to:
http://example.com/impact-game
Then on the server in PHP, I redirect them to
http://example.com/impact-game/?nocache
Would this be the correct way?
Will this also load the non-cached version of the game.min.js file?
1 decade ago
by cubiq
you could do that directly from the Apache server. Add an .htaccess file to your game root and put the following inside:
<filesMatch "\.(html|js|css)$">
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</filesMatch>
you need the headers apache module of course.
you can add any kind of file type to the list (png, jpg, ...) but that would impact bandwidth quite a bit.
I'm thinking it might be a good idea to combine cubiq's solution with the nocache postfix.
I would add an .htaccess file in order to force load the .html, .js, .css. This would make sure the user got the latest version of the code every time. And code is pretty fast to download.
Then, inside the code, I set "nocache" to my game's internal version number. This will force a reload of content only the first time. Every time the code's version number changes, it will force a fresh load of all the content again. So, basically every time there is new content, I will upload a new .js with a new version number.
Does this sound reasonable? Maybe this is something that should be added to the engine.
Page 1 of 1
« first
« previous
next ›
last »