I have a client that wants a site for people who are potentailly being abused, often by partners they live with.

He is under the impression that it is possible for there to be a "Button" that deletes the cache when the user presses it rather than going through the procedure of clearing the cache. I can see why this would be a goog thing to have, and wondered of js (or perhaps php might be the way to go)

I have done some research, and its looking a little dubious....

Am I right? Can anyone advise please?

Thanks

E

Recommended Answers

All 10 Replies

If that sort of thing was scriptable, it would be a hackers delight. They would do all sorts of nastiness to our computers.

Short of writing something viral (and certainly not in javascript), I think it safe to say that it can't be done.

Airshow

I have a client that wants a site for people who are potentailly being abused, often by partners they live with.

He is under the impression that it is possible for there to be a "Button" that deletes the cache when the user presses it rather than going through the procedure of clearing the cache. I can see why this would be a goog thing to have, and wondered of js (or perhaps php might be the way to go)

I have done some research, and its looking a little dubious....

Am I right? Can anyone advise please?

Thanks

E

The way to go?...
Well you don't need a button or script to keep the cache clean for some certain web page. You can prevent it altogether.

<META HTTP-EQUIV="Expires" CONTENT="-1">
 <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
 <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

Read more at http://www.daniweb.com/forums/post645889.html#post645889

but if you explicitly need a button to do that, you can also script it ...

Thanks posters

Interesting contributions. I have pursuaded my client that the best way to go is to have a button that then opens pages that tell users how to clear their caches.

But that header stuff looks interesting, and I read the link. So I will probably add that in too.

Thanks again

Thanks posters

Interesting contributions. I have pursuaded my client that the best way to go is to have a button that then opens pages that tell users how to clear their caches.

But that header stuff looks interesting, and I read the link. So I will probably add that in too.

Thanks again

...
That client of yours might happen to be some old hardcore coder himself, who doesn't deal with the Web anymore. Trying to pursuade him to the contrary, might just make you look young and unprofessional to him.

Yes, you can make a button which when pressed, would modify the Header of the Document (adding abovementioned meta tags) that will clear the current page cache for real!

Regards

Yes, I see what you mean (although he isn't a coder at all!)

Anyway, I am a bit confused here. People are telling me its not possible because that would be a hackers delight.

WOuld the button mean that the page is reloaded, with additional headers?

Would you please be able to show me how to link the header info to the button - is it just an onclick with javascript?

Thanks a lot

E

Maxelcat,

I'm confused too. This need thinking through.

If it's a page that's under your control, and you believe that meta tags are the way to go (I for one am yet to be convinced as there's no obligation on any server, proxy-server or browser to observe them), then you would serve it with the metas already in place. No need for a button/script to inject them.

If it's a page that's not under your control, then what is the mechanism by which a button/script can be made to act on it? Browser plugin? Nope, most people won't have it installed.

I think you need to be told considerably more about this approach before you can proceed.

Agreed though, you do have to find a diplomatic way to tell the client that his expectation may not be realistic. Similarly, you don't want to falsely fuel his expectation if you cannot then deliver a solution.

Airshow

Thanks

I have diplomatically told the clinet a few days ago that a simple button to press that clears the browser cache is a no no. I did this becaue a search indicated that it was likely to be a security issue. My mixim is that "All things are possible" with websites, and have generally found that to be the case. However, this one was looking like it was going to cost more than the rest of the site to impliment. The client agreed this wasn't worth it, didn't want even the slightest hint of a security issue and opted for the "Lets have instruction pages" - which is what his competitors do.

I knew at that time that there were header options, but I figured that might be unreliable - headers do appear to be somewhat flexible in how they are treated.

Now you mention it, if you're going down the headers route why have a button - its done anyway.

I wonder if I might add the headers, and then have instructions on how to clear your cache. Kind of a "Belt and braces" approach.

thanks for your comments

I wonder if I might add the headers, and then have instructions on how to clear your cache. Kind of a "Belt and braces" approach.

Good idea, but genuine HTTP headers stand a far greater chance of being observed than meta tags.

Whereas some servers promote metas to HTTP headers on-the-fly as the page is served, the vast majority do not.

With PHP, and several other server-side languages, setting HTTP headers is quite easy. See language reference.

This is the best I can find on the subject. It's well written and is worth reading through before making any decisions.

Airshow

Thanks

I have diplomatically told the clinet a few days ago that a simple button to press that clears the browser cache is a no no. I did this becaue a search indicated that it was likely to be a security issue. My mixim is that "All things are possible" with websites, and have generally found that to be the case. However, this one was looking like it was going to cost more than the rest of the site to impliment. The client agreed this wasn't worth it, didn't want even the slightest hint of a security issue and opted for the "Lets have instruction pages" - which is what his competitors do.

I knew at that time that there were header options, but I figured that might be unreliable - headers do appear to be somewhat flexible in how they are treated.

Now you mention it, if you're going down the headers route why have a button - its done anyway.

I wonder if I might add the headers, and then have instructions on how to clear your cache. Kind of a "Belt and braces" approach.

thanks for your comments

Your answer to the client was adequate; cause after all, even though they support header modifications via scripting - browsers are not required to execute and implement all the header modifications after the page was loaded.

Caching pages on a client or/and partially on local servers was an invention/solution required to free the host from stressfully frequent client requests and keep more bandwidth available for first time visitors.

Therefore preventing the page cache would only contribute on lowering your clients browsing experience.

On the other hand inclining to the "instruction page" solution is a better way to go, since it would guard you from possible failures and spare you from inconveniences most likely to be risen holding you accountable for them.

If competitors are going with the "clear-cache instruction page" - I strongly recommend you do the same!

Regards

thanks Chaps!

Have downloaded the cache tutorial for a rainy evening (of which there are an aweful lot round here...)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.