Name

Cache

Synopsis

HttpCachePolicy = Response.Cache

Returns an instance of the HttpCachePolicy class that contains the cache policy of the page. You can use the methods exposed by the HttpCachePolicy class with this class instance to examine which headers or parameters (if any) have been set to vary the output cache, or to modify the current cache settings. The HttpCachePolicy class includes the following members:

HttpCachePolicy member

Description

SetCacheability method

Controls caching by setting the HTTP Cache-Control header.

SetExpires method

Sets the HTTP Expires header. This method takes a DateTime argument that represents the absolute expiration time for the header.

SetLastModified method

Sets the HTTP Last-Modified header. This method takes a DateTime argument that represents the absolute expiration time for the header.

Insert method

Inserts an item into the cache and assigns it a key.

Item property

Returns an Object representing a cache item based on its key value or sets an item of data in the cache while assigning it a key value.

Remove method

Removes an item with a particular key value from the cache.

Parameters

HttpCachePolicy

An Object variable of type HttpCachePolicy.

Example

The example retrieves an instance of the HttpCachePolicy class into a local variable, sets the expiration time to two minutes after the page is processed, and then sets the cacheability of the of the page to Public. Finally, the Text property of the Message label control ...

Get ASP.NET in a Nutshell 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.