2025-04-27 07:49:33 -04:00

184 lines
6.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<TITLE>CacheControl</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
TempString = navigator.appVersion
if (navigator.appName == "Microsoft Internet Explorer"){
// Check to see if browser is Microsoft
if (TempString.indexOf ("4.") >= 0){
// Check to see if it is IE 4
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
}
}
else if (navigator.appName == "Netscape") {
// Check to see if browser is Netscape
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
//-->
</script>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_OnLoad()
Dim frmContents
On Error Resume Next
If Not Parent Is Nothing Then
Set frmContents = Parent.Contents
If Not frmContents Is Nothing Then
frmContents.Window.TOCSynch_Click
End If
End If
End Sub
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="MS-IT-LOC" Content="Internet Information Services">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H4><A NAME="_cachecontrol"></A><SUP></SUP>CacheControl</H4>
<H6>The CacheControl property allows you to set the HTTP/1.1 Cache-Control header in a response.Syntax</H6>
<P><B>Response.CacheControl </B>[<B>=</B> <I>Cache Control Header </I>]</P>
<P>&nbsp;</P>
<H6>Parameters</H6>
<DL>
<DT><I>Cache Control Header</I></DT>
</DL>
<P>The following is a partial list of values supported by the HTTP/1.1 Protocol. Please see the <B>Hypertext Transfer Protocol -- HTTP/1.1</B> specification at the <a href="http://www.microsoft.com/isapi/redir.dll?prd=external&sbp=W3org&pver=1.0&ar=specs" target=_blank><b><span class=le>World Wide Web Consortium Web site</span></b></a>, section 14.9, for more complete descriptions.</P>
<TABLE border=0 cellpadding=5 cols=2 frame=box rules=all>
<TR VALIGN="top">
<TD class=blue width=50%><B>Value</B></TD>
<TD class=blue width=50%><B>Description</B></TD>
</TR>
<TR VALIGN="top">
<TD width=50%>
<DL>
<DT>Private</DT>
</DL>
</TD>
<TD width=50%>
<DL>
<DT>A cache mechanism may cache this page in a Private cache and resend it only to a single client. This is the default value. Most proxy servers will not cache pages with this setting.</DT>
</DL>
</TD>
</TR>
<TR VALIGN="top">
<TD width=50%>
<DL>
<DT>Public</DT>
</DL>
</TD>
<TD width=50%>
<DL>
<DT>Shared caches, such as proxy servers, will cache pages with this setting. The cached page can be sent to any user.</DT>
</DL>
</TD>
</TR>
<TR VALIGN="top">
<TD width=50%>
<DL>
<DT>No-cache</DT>
</DL>
</TD>
<TD width=50%>
<DL>
<DT>Do not cache this page at all, even if for use by the same client. </DT>
</DL>
</TD>
</TR>
<TR VALIGN="top">
<TD width=50%>
<DL>
<DT>No-store</DT>
</DL>
</TD>
<TD width=50%>
<DL>
<DT>The response and the request that created it must not be stored on any cache, whether shared or private. The storage inferred here is non-volatile storage, such as tape backups. This is not an infallible security measure.</DT>
</DL>
</TD>
</TR>
</TABLE><BR>
<H6>Note</H6>
<P>Between your Web server and a user requesting your page, there may be proxy servers configured to cache Web pages for faster response times. Usually ASP pages are developed to be unique for each user, or may contain secure information.&nbsp; For this reason, IIS sets this property to "Private" so that proxy servers or other cache mechanisms will not cache pages.&nbsp; You can override this default value, setting it to any value supported by the HTTP/1.1 protocol, documented in the <B>Hypertext Transfer Protocol -- HTTP/1.1</B> specification at the <a href="http://www.microsoft.com/isapi/redir.dll?prd=external&sbp=W3org&pver=1.0&ar=specs" target=_blank><b><span class=le>World Wide Web Consortium Web site</span></b></a>.</P>
<P>If there is no cache mechanism between your Web server and a client computer, or if a proxy server is running HTTP/1.0, CacheControl will be ignored.</P>
<P>Setting CacheControl to "public" may seem to improve the performance of your .asp files, but it is discouraged if you generate custom HTML for every request, and a proxy server might interfere with the response.</P>
<P>The values for CacheControl are strings, and must be enclosed in quotation marks (" "). You must set CacheControl before any response is sent to the client unless response buffering is enabled.</P>
<H6>Example</H6>
<P>CacheControl comes before the &lt;HTML&gt; tag to ensure that it is set before content is sent to the client. </P>
<P>--- CacheControl_NoBuffer.asp ---</P>
<PRE><CODE>&lt;%
Response.Buffer = False
Response.CacheControl = "private"
%&gt;
&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Response.CacheControl Example&lt;/TITLE&gt;&lt;/HEAD&gt;
&lt;BODY&gt;
Output from this page is sent to the client as it is being processed.&lt;BR&gt;
It will not be cached.&lt;BR&gt;
Today is &lt;%= Date %&gt;, &lt;%= Time %&gt;&lt;BR&gt;
&lt;H3&gt;Please enter your credit card number:&lt;/H3&gt;
&lt;FORM NAME="Order" METHOD="POST" ACTION="order.asp "&gt;
&lt;INPUT TYPE="TEXT" NAME="CreditCard"&gt;
&lt;INPUT TYPE="SUBMIT" VALUE="Submit" NAME="Submit"&gt;
&lt;/FORM&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</CODE></PRE>
<P>--- CacheControl_Buffer.asp ---</P>
<PRE><CODE>&lt;% Response.Buffer = True %&gt;
&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Response.CacheControl Example&lt;/TITLE&gt;&lt;/HEAD&gt;
&lt;BODY&gt;
Output from this page is sent to the client once it is completely processed by the server, so we can set CacheControl anytime.&lt;BR&gt;
&lt;% Response.CacheControl = "private" %&gt;
It will not be cached.&lt;BR&gt;
Today is &lt;%= Date %&gt;, &lt;%= Time %&gt;&lt;BR&gt;
&lt;H3&gt;Please enter your credit card number:&lt;/H3&gt;
&lt;FORM NAME="Order" METHOD="POST" ACTION="order.asp "&gt;
&lt;INPUT TYPE="TEXT" NAME="CreditCard"&gt;
&lt;INPUT TYPE="SUBMIT" VALUE="Submit" NAME="Submit"&gt;
&lt;/FORM&gt;
&lt;/BODY&gt;</CODE></PRE>
<P>&lt;/HTML&gt;</P>
<PRE><CODE> </CODE></PRE>
<H6>Applies To</H6>
<P><A HREF="/iishelp/iis/htm/asp/vbob5sj8.htm"><B>Response</B> Object</A></P>
<hr class="iis" size="1">
<p align="center"><em><a href="../../../common/colegal.htm">&copy; 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
</BODY>
</HTML>