Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a "clear cache" button for my site?

I'd like to create a button on my site that COMPLETELY clears my cache. As neither Safari's nor Chrome's features work at all it seems. Is this possible?

like image 859
alt Avatar asked Jun 27 '11 03:06

alt


2 Answers

Not possible. That'd expose low-level functionality to public access. Even if an exploit would simply empty your cache, it'd still be undesireable. Firefox and Chrome both use shift-ctrl-del for this, so at the cost of actually having to use your keyboard, you can do the same thing without the security risk.

like image 65
Marc B Avatar answered Oct 31 '22 21:10

Marc B


It sounds like you want to clear the cached data that sits between your server and your browser, not the data that the browser has cached. A copy of your resources mat be sitting on a machine between your client computer and your server, and that is returning the cached copy, instead of asking your server for the data again.

You should read up on different caching methods, so you can set up certain types of files to be cached for a certain amount of time etc. Try this for starters.


I usually set up static resources (css, js, etc.) to be cached for a long period of time, but I change the URL when I have made changes to it. I usually do this by rewriting the request url so /resources/dummy/file.css becomes /resources/file.css and I can change dummy whenever I want. This creates the allusion of a different file (that hasn't been cached yet) but I don't have to rename the file.

RewriteRule  resources/[^/]+/([^/]+)$  resources/$1
like image 37
BudgieInWA Avatar answered Oct 31 '22 20:10

BudgieInWA