[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.caching

Help I *want* caching but IE won't give it to me (consistently.

Mark S.

6/7/2006 5:25:00 AM

On a static page I have:
<script type="text/javascript"
src="http://myServer/default.aspx?siteID=1"></script>

The aspx page (c# dotnet 2.0) builds a custom javascript file and returns it
to the browser. default.aspx only needs to be built once, per query string,
and then I would like the browser to Cache it (I'd take a 302, but would
prefer a full cache).

default.aspx code includes:
<%@ OutputCache Duration="604800" Location="Client" VaryByParam="None" %>
Response.ContentType = "application/x-javascript";

And IIS 6 (Windows 2003 Server) sets the expire time to two weeks in
advance.
Here are the returned headers:

(Response Status) HTTP/1.1 200 OK
Cache-Control private, max-age=604800
Content-Encoding gzip
Content-Type application/x-javascript; charset=utf-8
Date Wed, 07 Jun 2006 05:17:16 GMT
Expires Wed, 14 Jun 2006 05:17:16 GMT
Last-Modified Wed, 07 Jun 2006 05:17:16 GMT
Server Microsoft-IIS/6.0
Transfer-Encoding chunked
Vary Accept-Encoding
X-AspNet-Version 2.0.50727

The strange thing is if I visit the page, close the browser and then return
to the site default.aspx is cached by IE. However, if I hit reload, the page
auto refreshes or I click on a link and return with the back button, then IE
goes and gets a new copy of default.aspx.

How can I get default.aspx to be cached by IE until the expiration date?

TIA,

M








1 Answer

Mark S.

6/9/2006 6:37:00 AM

0

The answer is:

Response.Cache.SetExpires(DateTime.Now.AddMonths(1));
Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
Response.Cache.SetAllowResponseInBrowserHistory(true);
Response.Cache.SetValidUntilExpires(true);
DateTime LastModified = new DateTime(2006, 01, 01);
Response.Cache.SetLastModified(LastModified);
Response.Cache.VaryByParams.IgnoreParams = true;
Response.Cache.SetETag("50f59e42f4d8bc1:cd7");