Name

CacheControl — Response.CacheControl[= ProxyCacheControlSetting ]

Synopsis

The CacheControl allows you to set whether proxy servers serving your pages can cache your page. If your page's content is large and doesn't change often, you might want to allow proxy servers to cache the page and thus serve it faster to requesting client browsers.

Parameters

ProxyCacheControlSetting

Determines whether proxy servers used to access your web site can cache your pages. The default for this property is Private, indicating that the proxy servers cannot cache your page. If this value is Public, however, proxy servers can cache the page. Note that Private and Public are string values.

Example

Setting this property is a simple affair, as the following code demonstrates. You may be asking yourself if there is any way to determine if the client is accessing the web page through a proxy server. Although there is, if you know ahead of time of the existence of the possible proxy servers, this is problematic and cumbersome. Furthermore, there is no need to determine this before setting this property. Either the client request is being handled by a proxy server and this property will affect the caching of the page, or this property is completely ignored.

<% ' The following code sets the HTTP cache control header so ' that this page can be cached by the proxy servers being ' used to access the page. Response.CacheControl = "Public" %> <HTML> <% ' Note that the CacheControl property was set BEFORE the ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.