Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Caching Problem

Status
Not open for further replies.

rewdee

Programmer
Aug 17, 2001
295
0
0
US
I'm still having the caching problem as described in previous thread.

DotNetGnat mentioned "the best way to fix this is to attach a random string to the end of the URL." I'm unclear how to implement this solution. Won't the string itself be cached too?

Does anyone know of a site or some resource to implement this?

Thanks,
Rewdee
 
The trick is to CHANGE the random string each time you use that page's url. That way it never matches the previous url, so the cached copy isn't used. The most common way to do this is to simply use the date/time, since it changes every second (or less, depending) so it shouldn't duplicate.



Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
sorry forgot about your other thread...something like this will work...as Tracy suggests timestamp is the easiest method...

you can have a javascript function something like this:
Code:
<script language="javascript">
function getRandomstring()
{
return new Date().getTime();
}
</script>

and call this function in the query string...

-DNG
 
this link also has another cachebuster function...just try and see which one is good for you...

-DNG
 
Thanks for the quick responses again.

The problem with this solution though, even if I have a random string at the end of the url, when a user clicks the back button, the browser has cached the last page (no matter what the random string is). This is deemed a security risk because someone could log off and then by just clicking the back button, they can re-enter as an authorized user.

Again I've used this code that works in IE but not in Firefox.
Code:
'Prevent caching on the client
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1	
Response.Expiresabsolute = Now-1  
Response.AddHeader "cache-control","dim"   
Response.buffer = false
Any ideas are more than welcome.

Thanks,
Rewdee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top