Another important function of Response object is the output of HTTP headers to
the client. As part of the HTTP header, these types of response objects should
be sent before sending any body content to the client.
Response.Expires
property sets the length of the time in minutes that the HTML page can be cached
on the browser to calculate the absolute expires date & time according to the
date & time on the server for the HTTP Expires header.
Syntax:
Response.Expires [=number]
Or in an ASP file. Imply
<% Response.Expires = number %>
Parameters:
number
The parameter "number" is the value of
duration time in minute of a page in a cache. The data type of
"number" is numbers. A value of negative number means immediate expiration. When
the calculated absolute expires date from the supplied value of number exceeds
January 18, 2038, IIS server will returns an error.
Remarks:
If the same page is requested by client before the page expires, the cached
version will be displayed by the client.
If there are multiple Response.Expires
or Response.ExpiresAbsolute on the same page, the
web server will use the shortest time period.
Since the system time on the client may not be the same as the system time on
the server, setting the parameter of expires to zero sometime does not have the
effect of expiring the response immediately. Therefore setting the parameter of
expires to a negavtive number can ensure the expiring of the response
immediately.
Examples:
Default value with No Response.Expires
ASP script command:
<% %>
HTTP header response:
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Tue, 31 Jan 2012 15:19:08 GMT
X-Powered-By: ASP.NET
Content-Length: 0
Content-Type: text/html
Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
Cache-control: private
Response.Expires with value 10
ASP script command:
<% Response.Expires =
10 %>
HTTP header response:
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1 Date: Tue, 31 Jan 2012 15:19:08 GMT
X-Powered-By: ASP.NET
Content-Length: 0
Expires: Tue, 31 Jan 2012 15:29:08 GMT:29:08 GMT Content-Type: text/html
Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
Cache-control: private
Response.Expires with value 0
ASP script command:
<% Response.Expires =
0 %>
HTTP header response:
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1 Date: Tue, 31 Jan 2012 15:19:08 GMT
X-Powered-By: ASP.NET
Content-Length: 0
Expires: Tue, 31 Jan 2012 15:19:08 GMT:19:08 GMT Content-Type: text/html
Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
Cache-control: private
Response.Expires with value -1
ASP script command:
<% Response.Expires =
-1 %>
HTTP header response:
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1 Date: Tue, 31 Jan 2012 15:19:08 GMT
X-Powered-By: ASP.NET
Content-Length: 0
Expires: Tue, 31 Jan 2012 15:18:08 GMT:18:08 GMT Content-Type: text/html
Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/
Cache-control: private
Response.ExpiresAbsolute
property sets the actual expire date and time that the HTML page can be
cached on the browser for the HTTP Expires header.
Syntax:
Response.ExpiresAbsolute [=[date][time]]
Or in an ASP file. Imply
<% Response.Expires = [date][time] %>
Parameters:
date
The parameter "date" is the value of
expire date of a page in a cache. The data type of
"date" is window date format. In general, Date values must be enclosed
within pound signs (#) and be in the format M/d/yyyy. But the value sent in the
HTTP Expires header will convert to the RFC-1123 date format. If the value of
date is not set, the default value of date is the day of the ASP file run. When
the absolute expires date from the supplied value of number exceeds
January 18, 2038, IIS server will returns an error.
time
The parameter "time" is the value of
expire time of a page in a cache. The data type of
"time" is window time format. In general, time values must be enclosed
within pound signs (#) and be in the format hh:mm:ss. But the value sent in the
HTTP Expires header will convert to the RFC-1123 date format with GMT time zone.
If the value of time is not set, the default value of time is the midnight of
the day of the ASP file run in GMT format.
Remarks: Remarks:
The value of the parameters must be enclosed in pound marks (# #)
If the same page is requested by client before the page expires, the cached
version will be displayed by the client.
If there are multiple
Response.ExpiresAbsolute or Response.Expires in the same page, the
web server will use the shortest time period.
Examples:
Default value with No Response.ExpiresAbsolute
ASP script command:t command:
<% %>
HTTP header response:
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Tue, 31 Jan 2012 15:19:08 GMT
X-Powered-By: ASP.NET
Content-Length: 0
Content-Type: text/html
Set-Cookie: ASPSESSIONIDPPPP=PPPPPPPP; path=/ Cache-control: private
Response.ExpiresAbsolute with value "February 18, 2012 13:30:15"