HighTechTalks DotNet Forums  

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

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss Help I *want* caching but IE won't give it to me (consistently.) in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Mark S.
 
Posts: n/a

Default Help I *want* caching but IE won't give it to me (consistently.) - 06-07-2006 , 01:25 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









Reply With Quote
  #2  
Old   
Mark S.
 
Posts: n/a

Default Re: Help I *want* caching but IE won't give it to me (consistently.) - 06-09-2006 , 02:37 AM






The answer is:

Response.Cache.SetExpires(DateTime.Now.AddMonths(1 ));
Response.Cache.SetCacheability(HttpCacheability.Se rverAndPrivate);
Response.Cache.SetAllowResponseInBrowserHistory(tr ue);
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");





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.