garriganlyman
asked on
Changing "Cache-Control: Private" setting in IIS 6
Hello,
We are attempting to change the setting for the "Cache-Control" value from the default of "Private" to a new setting with an expiration time.
We have tried using the HTTP HEADER "Add" function in IIS but it does not seem authoritative when using CURL on the URL.
We have also used the following script to change in the metabase (and then hard reset IIS)
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C:\Documents and Settings\glg.admin>Cd C:\inetpub\adminscripts\
C:\Inetpub\AdminScripts>CS CRIPT adsutil.vbs set w3svc/SITENUMBER/root/incl udes/c
achecontrolcustom "public"
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
cachecontrolcustom : (STRING) "public"
C:\Inetpub\AdminScripts>
While the metabase file shows the cache-control as public. Using Curl on the URL still shows "Cache-Control: Private"
Our CDN can not long term cache the content without this setting being changed. Microsoft only points out the method above (from the Dos prompt) for changing the cache control header. Are we to resort to doing this code side? Is there no other way to change it server wide?
Our Curl statement ends up looking like this:
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
P:\>cd C:\curl
P:\>c:
C:\curl>curl -I http://wwww.domainname.com/includes/header.aspx
HTTP/1.1 200 OK
Date: Tue, 30 Sep 2008 21:54:36 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Cache-Control: max-age=86000, no-check
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 3080
Our network setup is 2 web servers behind a zeus load balancer which are then serving as origin for a content delivery network. The content delivery network has shielding enabled but cannot hold the contnet long enough to be effective. Long term result - a 503 error in accessing content from origin will drop both servers from the load balancing pool and show errors to the user. Note that the CDN Curl statement below shows the cache dropping the more liberal of the two Cache-Control settings.
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\curl> curl -I http://cache.domainname.com/includes/header.aspx
HTTP/1.1 200 OK
Date: Tue, 30 Sep 2008 21:59:18 GMT
Server: PWS/1.3.26
Transfer-Encoding: chunked
X-Px: ms sfo-agg-n35 (sfo-agg-n50), ms sfo-agg-n50 (jfk-agg-x2), ms jfk-agg-x2 (
origin)
Content-Type: text/html; charset=utf-8
Cache-Control: private
Connection: keep-alive
Thanks in advance!
Chris
We are attempting to change the setting for the "Cache-Control" value from the default of "Private" to a new setting with an expiration time.
We have tried using the HTTP HEADER "Add" function in IIS but it does not seem authoritative when using CURL on the URL.
We have also used the following script to change in the metabase (and then hard reset IIS)
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C:\Documents and Settings\glg.admin>Cd C:\inetpub\adminscripts\
C:\Inetpub\AdminScripts>CS
achecontrolcustom "public"
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
cachecontrolcustom : (STRING) "public"
C:\Inetpub\AdminScripts>
While the metabase file shows the cache-control as public. Using Curl on the URL still shows "Cache-Control: Private"
Our CDN can not long term cache the content without this setting being changed. Microsoft only points out the method above (from the Dos prompt) for changing the cache control header. Are we to resort to doing this code side? Is there no other way to change it server wide?
Our Curl statement ends up looking like this:
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
P:\>cd C:\curl
P:\>c:
C:\curl>curl -I http://wwww.domainname.com/includes/header.aspx
HTTP/1.1 200 OK
Date: Tue, 30 Sep 2008 21:54:36 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Cache-Control: max-age=86000, no-check
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 3080
Our network setup is 2 web servers behind a zeus load balancer which are then serving as origin for a content delivery network. The content delivery network has shielding enabled but cannot hold the contnet long enough to be effective. Long term result - a 503 error in accessing content from origin will drop both servers from the load balancing pool and show errors to the user. Note that the CDN Curl statement below shows the cache dropping the more liberal of the two Cache-Control settings.
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\curl> curl -I http://cache.domainname.com/includes/header.aspx
HTTP/1.1 200 OK
Date: Tue, 30 Sep 2008 21:59:18 GMT
Server: PWS/1.3.26
Transfer-Encoding: chunked
X-Px: ms sfo-agg-n35 (sfo-agg-n50), ms sfo-agg-n50 (jfk-agg-x2), ms jfk-agg-x2 (
origin)
Content-Type: text/html; charset=utf-8
Cache-Control: private
Connection: keep-alive
Thanks in advance!
Chris
ASKER
That's an excellent question. When running curl on an html file the cache-control header value is correct. If the value is being set by the ASP.NET runtime - does that mean that it needs to be changed on the fly in the code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This solution is now working in our staging environment - THANKS DAVE!
I believe the Cache-control header is being set by the ASP.Net runtime and since it is set IIS will not overwrite it.
Dave Dietz