ASP.Net Caching

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I'm using ASP.Net with an UpdatePanel. When the screen is exercised via a
Web Test, the Web Test shows that the AJAX scripts are downloaded for every
partial post back.

My impression was that IE would cache these scripts so that the AJAX script
download would only occur once.

What am I missing?
 
Dave said:
I'm using ASP.Net with an UpdatePanel. When the screen is exercised via a
Web Test, the Web Test shows that the AJAX scripts are downloaded for every
partial post back.

My impression was that IE would cache these scripts so that the AJAX script
download would only occur once.

What am I missing?


Use fiddler to see what is present in the request/response exchanges between
IE and web server.

Are the scripts coming from a folder or a webresource ?

Do the JS resources come with Last-Modified and ETag headers and do they
have an Expires header set in the future? What is specified in the
Cache-Control header coming from the server?

What is IE sending in its request for these resouces, is a If-Modified-Since
header and/or a If-None-Match match header present?

Is IE caching other resouces as expected? Is the temporary internet files
setting on automatic?

There was a bug in IE cache handling (I haven't tested it recently) when the
ETag of a resource changed but the Last-Modified hasn't (on IIS this can
happen when some values in the metabase are changed), IIS responds with a
full 200 response but IE doesn't cache the item with the new ETag because
the Last-Modified date is the same as the existing cached resource.
 
Hi Dave,

From your description, the "Caching" you mentioned here is the cache of the
AJAX client script rather than ASP.NET server-side output cache, correct?

As for client-side scripts or other static resource's caching, it mostly
depend on the client-browser's interpretion of the resources(whether it
detect any change in the url or the httpheader's last modified value
changed). Also, there is specific configuration in client browser to
customize it. For example, you can change the behavior in IE via the
following setting:

**Tools-->internet options---> "General Tab"

**In the "Browsing history" section, click " Settings" button

You'll find the "check for newer versions for the stored page" item

Also, for the behavior you saw, I suspect that whether it is also related
to the webtest tools which may generate some additional header or url
querystring which make the server-side emit different script url for the
AJAX script. This may also make the client browser think the file need
update. Anyway, you can use "Web Development Helper" tool to watch the
behavior when you manually do postback operations on the AJAX page. Based
on my test, for normal AJAX postback, the script resoures are not download
everytime.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Dave,

Have you got any progress on this issue or does the suggestion in previous
message help some?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (Steven Cheng [MSFT])
Organization: Microsoft
Date: Mon, 28 Jul 2008 03:46:54 GMT
Subject: RE: ASP.Net Caching
 
Thank you for the excellent response.

Yes, my question pertains to the caching of the AJAX scripts on the client.

Regarding the "check for newer versions for the stored page" setting, when
it is set to "Never", the AJAX scripts are NOT downloaded everytime.
Otherwise, they seem to be. What setting do you recommend?

I'll try the Web Development Helper when I return from vacation.

Thanks!
Steven Cheng said:
Hi Dave,

Have you got any progress on this issue or does the suggestion in previous
message help some?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (Steven Cheng [MSFT])
Organization: Microsoft
Date: Mon, 28 Jul 2008 03:46:54 GMT
Subject: RE: ASP.Net Caching
Hi Dave,

From your description, the "Caching" you mentioned here is the cache of the
AJAX client script rather than ASP.NET server-side output cache, correct?

As for client-side scripts or other static resource's caching, it mostly
depend on the client-browser's interpretion of the resources(whether it
detect any change in the url or the httpheader's last modified value
changed). Also, there is specific configuration in client browser to
customize it. For example, you can change the behavior in IE via the
following setting:

**Tools-->internet options---> "General Tab"

**In the "Browsing history" section, click " Settings" button

You'll find the "check for newer versions for the stored page" item

Also, for the behavior you saw, I suspect that whether it is also related
to the webtest tools which may generate some additional header or url
querystring which make the server-side emit different script url for the
AJAX script. This may also make the client browser think the file need
update. Anyway, you can use "Web Development Helper" tool to watch the
behavior when you manually do postback operations on the AJAX page. Based
on my test, for normal AJAX postback, the script resoures are not download
everytime.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#noti f
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thank you for the comprehensive list of things to try. I will try them when
I'm back from vacation. Thanks again!
 
Thanks for your reply Dave,

As for the setting in browser, I think the default "Automatically" would be
ok.

Also, enjoy your vacation, and welcome to post here when you come back on
this again.

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?RGF2ZQ==?= <[email protected]>
References: <[email protected]>
Subject: RE: ASP.Net Caching
Date: Thu, 31 Jul 2008 08:21:01 -0700
 
As you implied, when fiddler was used, it showed that the Microsoft
JavaScript files WERE cached.

Unfortunately, my JavaScripts, Images, and CSS files are not cached and I
would like them to. The remainder of this Email will address my files as
opposed to the AJAX files.

Regarding your questions:

a. Are the scripts coming from a folder or a webresource? My files are
obtained from a web folder.

b. Do the JS resources come with Last-Modified and ETag headers and do they
have an Expires header set in the future? What is specified in the
Cache-Control header coming from the server?

The Response Header from the JavaScript that ISN'T cached is:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/9.0.0.0
Date: Tue, 05 Aug 2008 17:04:30 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: application/x-javascript
Content-Length: 1561
Connection: Close


The Response Header from the AJAX JavaScript that IS cached is:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/9.0.0.0
Date: Tue, 05 Aug 2008 17:04:30 GMT
X-AspNet-Version: 2.0.50727
Content-Encoding: gzip
Cache-Control: public
Expires: Wed, 05 Aug 2009 17:03:49 GMT
Last-Modified: Thu, 08 May 2008 16:01:26 GMT
Content-Type: application/x-javascript
Content-Length: 6387
Connection: Close


c. What is IE sending in its request for these resouces, is a
If-Modified-Since
header and/or a If-None-Match match header present?

The Request header for the JavaScript that isn't cached is:

GET /MyProject/JavaScript/LinkButton.js HTTP/1.1
Accept: */*
Referer: http://MyPage.aspx
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Proxy-Connection: Keep-Alive
Host: localhost.:2095

d. Is IE caching other resouces as expected? Is the temporary internet files
setting on automatic?

Yes, the AJAX files are being cached. The temporary internet files is set
to automatic.

Again, thanks for your help with this!
 
Dave said:
As you implied, when fiddler was used, it showed that the Microsoft
JavaScript files WERE cached.

Unfortunately, my JavaScripts, Images, and CSS files are not cached and I
would like them to. The remainder of this Email will address my files as
opposed to the AJAX files.

Regarding your questions:

a. Are the scripts coming from a folder or a webresource? My files are
obtained from a web folder.

b. Do the JS resources come with Last-Modified and ETag headers and do they
have an Expires header set in the future? What is specified in the
Cache-Control header coming from the server?

The Response Header from the JavaScript that ISN'T cached is:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/9.0.0.0
Date: Tue, 05 Aug 2008 17:04:30 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: application/x-javascript
Content-Length: 1561
Connection: Close


The Response Header from the AJAX JavaScript that IS cached is:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/9.0.0.0
Date: Tue, 05 Aug 2008 17:04:30 GMT
X-AspNet-Version: 2.0.50727
Content-Encoding: gzip
Cache-Control: public
Expires: Wed, 05 Aug 2009 17:03:49 GMT
Last-Modified: Thu, 08 May 2008 16:01:26 GMT
Content-Type: application/x-javascript
Content-Length: 6387
Connection: Close


c. What is IE sending in its request for these resouces, is a
If-Modified-Since
header and/or a If-None-Match match header present?

The Request header for the JavaScript that isn't cached is:

GET /MyProject/JavaScript/LinkButton.js HTTP/1.1
Accept: */*
Referer: http://MyPage.aspx
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Proxy-Connection: Keep-Alive
Host: localhost.:2095

d. Is IE caching other resouces as expected? Is the temporary internet files
setting on automatic?

Yes, the AJAX files are being cached. The temporary internet files is set
to automatic.

Again, thanks for your help with this!


First thing I would do is test this with IIS not the development server.

Developement server is fine for quick testing of .NET code etc but its not
something you would use to test the general Request/Response behaviour the
site proper.

I think you'll find things work fine under IIS.
 
"Automatically" is working well. Also found that running IIS from a
different machine (independently of the Webtest) solved the problem. Thanks
a ton!
 
Thanks for your followup Dave.

I'm glad that it works.

Have a nice day!

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Subject: RE: ASP.Net Caching
Date: Fri, 8 Aug 2008 11:45:00 -0700
 
Back
Top