Click to See Complete Forum and Search --> : caching ASP pages


Gollum
05-27-2003, 05:43 AM
Hi Guys,

I'm trying control the caching on ASP generated pages as a number of pages my app generates never change (in fact they are filled with javascript as this provides a neat way to bundle the js code with the application dll)

anyway, I have set the cachecontrol on the response (equivalent to going Response.CacheControl = "Public") but I am noticing that the server is handling these pages over and over even though the url for these pages is still the same.

It's as if these pages aren't being cached and the browser is going back to the server each time. I've tried with both IE and Netscape with the same results.

Strangely, when I look in the Temporary Internet Files folder (for IE) the pages are there.

Am I missing something? How can I have these pages cached?

Bullschmidt
05-29-2003, 03:01 AM
Here is what I put at the top of my database-related ASP pages to prevent caching:

<%
Response.Expires = -1000
%>

Gollum
05-29-2003, 03:07 AM
But I want these pages to be cached. Is this sensible or am I barking up the wrong tree?

Bullschmidt
05-29-2003, 03:12 AM
My understanding is that without something like Response.Expires = -1000 or something similar that the pages would be allowed to be cached by the user's browser if his browser settings allow this.

In IE Tools | Internet Options | General tab | Settings button | Check for newer versions of stored pages...

Gollum
05-29-2003, 06:16 AM
AHA!

I've added a bit that says...

Response.Expires = <some day a year from now>

and this gives me the behaviour I was after.

Without it, it seems the browser goes back to the server every page (except when you tell it to never look). With it, the browser can compare the date with it's version of now and decide whether to download it again.

Thanks Bullschmidt