Forum Moderators: open

Message Too Old, No Replies

Prevent caching with javascript

         

hermes

10:12 pm on Dec 2, 2005 (gmt 0)

10+ Year Member



"1) No-Cache Header is the ONLY thing that will do really to prevent caching.
2) META tags are ignored. Therefore: META TAGS ARE USELESS TO YOU.
3) Expires = -1 header will not really do as this will still not stop it being entered in the Temp internet files for use in special situations - such as when the BACK button is pressed.

CONCLUSION: if want to stop caching - have to use No-cache header."

BUT BUT there is always a way! Does anyone know a way to prevent caching without using headers? My host does not support php headers. So, need find a way just using html or javascript or php (but not php headers).

I guess javascript must provide some avenues. Anyone know any of these?

jdMorgan

10:36 pm on Dec 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JavaScript executes client-side. So... By the time the JS is processed, it's too late; The document has already been cached if it's going to be cached.

With respect, if you can't send simple headers with php, it's time for a new host.

Jim

hermes

10:47 pm on Dec 2, 2005 (gmt 0)

10+ Year Member



Found this on the web. Did some preliminary tests with the concept but couldn't get it working. Is it a wind up?

[tactika.com...]

-------

Instruct the browser to bypass the Cache
Put that in the HEAD section of the HTML page
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

However, MS IE (almost all versions) do not process the instruction properly due to the cache mechanism.
The workaround is to included a second <HEAD> section at the bottom of the page (no joke!).

<HTML><HEAD>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="REFRESH" CONTENT="5">
</HEAD>
<BODY>
This page has 2 HEAD sections to properly bypass the cache in all browser.
</BODY>
<HEAD>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</HEAD>
</HTML>


NOTE: the above example uses META HTTP-EQUIV="REFRESH" to make the browser reload the page automatically
after 5 seconds, this is for demonstration purpose only (to see that the cache is actually bypassed). This
has nothing with the bypassing of the cache itself.

---------