C
C
CrewCut2017-09-09 12:17:29
JavaScript
CrewCut, 2017-09-09 12:17:29

Is there any working way to bind the reset button with clearing the cache?

Now browsers have begun to cache more and more, it is not so easy for an ordinary user to show the current version of the site. Explaining where to click is a path to nowhere, I want to place a button that will refresh the page, as if ctrl + F5 were pressed.
I re-read all the answers on the topic on stackoverflow, but nothing works (I check in chrome).

location.reload(true);

var xhr = new XMLHttpRequest();
xhr.open("GET", uriOfCachedPage, true);
xhr.setRequestHeader("Cache-Control", "max-age=0");
xhr.send();

window.location.reload(true);

None of this wants to work. The server is caching through .htaccess, perhaps because of this. But turning it off is not an option. That being said, updating ctrl+F5 works fine. Tell me how to be, where to dig?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
ThemeZV, 2017-09-09
@ThemeZ

Change the name of the included files for each version of the site.
Or add a get parameter (eg /static/css/styles.css?v=2).

L
Leo Developer, 2017-09-09
@crazy_leo

Files index.php>
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"
</Files>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question