Link:http://output.to/sideway/default.asp?qno=120100033 CacheControl
Response Object
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.CacheControl Property
Response.CacheControl property set the value of
the HTTP/1.1 Cache-Control header in the Response.Syntax to indicate whether the
proxy servers or other cache mechanism can cache the HTML output.
Syntax:
Response.CacheControl [=Cache Control Header]
Or in an ASP file. Imply
<% Response.CacheControl = Cache Control Header %>
Parameters:
Cache Control Header
The parameter "Cache
Control Header" is the value of the HTTP/1.1 Cache-Control header to output in
the HTTP header. The data type of
"Cache Control Header" is strings and the value must be enclosed in quotation marks (" "). The
possible values of Cache Control Header are
Value | Description |
public | To specify the response can be cached by a shared caches and
to indicate that the responses can be sent to any client |
private | Default value; To specify the response can be cached by a
private or non-shared cache and to indicate that the response is only intended
for the specified client. The term "private" only specify the type of cached
used not the privacy of the response. |
no-cache | To specify the response cannot be reused for the subsequent
request and to indicate that the cached responses cannot be reused again even
the response for the same client |
no-store | To specify no part of the response can be stored in any type of non-volatile storage
for both the shared and the private caches. Th |
max-age = delta-seconds
| To specify the maximum amount of time before the cached response in a cache
be considered as expired. The "max-age" directive also overrides the Expires
Header. In general, the response is cacheable unless other restrictive cache
directive is also present. |
s-maxage = delta-seconds
| To specify the maximum amount of time before the cached response in a
public or shared cache be considered as expired. The "s-maxage" directive also
overrides both the Expires Header and the "max-age" directive. |
must-revalidate | To specify the cached response should follow the
cache control directive for supporting a reliable operation or transaction and
to inform the cache that the cached response should be revalidated with the
original server after the cached response is stale. |
proxy-revalidate | To specify the cached response in a public or
shared cache should follow the cache control directive for supporting a reliable
operation or transaction and to inform the public or shared cache that the
cached response should be revalidated with the original server after the cached
response is stale. |
no-transform | To specify both the non-modifiable headers and any
aspect of the entity-body specified by the non-modifiable headers of the cached response
in a cache should not be transform |
cache-extension | To extend
the Cache-Control header field through the adding of additional informational
extensions and behavioral modifier extensions. The new cache extension, if
understanded by the application will be recognized as the additional modifier
that associated with the standard cache control directive. Or the new cache
extension will be ignored and the application will default to the standard cache
control directive |
Remarks:
The Cache-Control response header was added to HTTP 1.1 for defining how the
pages should be handled by caches.
If there is no cache mechanism between the web server and the client, or the
proxy server is running HTTP/1.0, the Cache-Control response header will be
ignored
If the response buffering is not enbled, the CacheControl header setting must be
set before any response is sent to the client.
The default value of Cache-Control response header of the IIS web server is
"Private" which tells cache not to cache pages. Setting the value of
Cache-Control response header to "Public" which tells cache to cache page for
faster response times. But dynamic pages generated by the response of ASP file
may also be interfered by the cache which might delay the response.
Examples:
Default value with No Response.CacheControl
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.CacheControl
with value "public"
ASP script command:
<% Response.CacheControl = "public" %>
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: public
-
Response.CacheControl with value "no-cache"
ASP script command:
<% Response.CacheControl = "no-cache" %>
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: no-cache
-
Response.CacheControl with value "no-store"
ASP script command:
<% Response.CacheControl = "no-store" %>
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: no-store
-
Response.CacheControl with value "max-age=86400"
ASP script command:
<% Response.CacheControl = "max-age=86400" %>
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: max-age=86400
-
Response.CacheControl with value "s-maxage=86400"
ASP script command:
<% Response.CacheControl = "s-maxage=86400" %>
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: s-maxage=86400
-
Response.CacheControl with value "must-revalidate"
ASP script command:
<% Response.CacheControl = "must-revalidate" %>
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: must-revalidate
-
Response.CacheControl with value "proxy-revalidate"
ASP script command:
<% Response.CacheControl = "proxy-revalidate" %>
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: proxy-revalidate
-
Response.CacheControl with value "no-transform"
ASP script command:
<% Response.CacheControl = "no-transform" %>
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: no-transform
-
Response.CacheControl with cache-extension
Example from rfc2616, a cache-extension of new "community"
value is added as
the modifier directive to the "private" value.
ASP script command:
<% Response.CacheControl = "private,
community=""UCI""" %>
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, community="UCI"
-
Response.CacheControl with multiple
values
Example: max-age value plus must-revalidate value
to specify that the cache must revalidate the response after the cached response
is stale
ASP script command:t command:
<% Response.CacheControl = "max-age=86400,
must-revalidate" %>
HTTP header response: 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: max-age=86400,
must-revalidate
-
Response.CacheControl with multiple
values
Example:
public value plus no-cache value to specify that the response can be cached in a
public cache but the response cannot be reused for the subsequent
request again even
for the same client.
ASP script command:t command:
<% Response.CacheControl = "public,
no-cache" %>
HTTP header response: 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: public, no-cache
Link:http://output.to/sideway/default.asp?qno=120100028 ASPError Object
ASPError Object
ASPError object of ASP is related to the information storage about an error
condition of an ASP page or the information about an error that has occurred
during procession the script in an ASP. There is no ASPError Method for the
ASPError object of ASP. Only read-only properties are available for the
ASPError object of ASP. And the properties of
ASPError object of ASP is returned by the Server.GetLastError method.
Properties
Property |
Description |
ASPCode |
A read only property to retrieve the error code generated by the web server. |
ASPDescription |
A read only property to retrieve a more detailed description of the error that
related to the ASP engine. |
Category |
A read only property to retrieve the category of the error source. A error can be
generated by the ASP engine of the web server, the scripting language, or the
object or component of ASP. |
Column |
A read only property to retrieve the column position of the ASP page that caused
the error. |
Description |
A read only property to retrieve a short description of the error. |
File |
A read only property to retrieve the name of the ASP file that generated the
error during script processing. |
Line |
A read only property to retrieve the line of the ASP page that caused the error. |
Number |
A read only property to retrieve the standard COM error code generated by the COM
component. |
Source |
A read only property to retrieve the actural source code, if available, of
the line that caused the error. |
Remarks
When processing an ASP file with an error, the web server will first generate a
500;100 custom error. And by default, the 500;100 custom error will cause a
processing transfer to the default 500-100.asp file.
-
After the 500;100 custom error processing, an instance of ASPError object for an
ASP file is also created by the web server specially for an ASP file when
processing an ASP file with an error.
-
The ASPError object of an ASP file can also be used as the respond of an HTTP
error for creating suitable custom error mesages to the client.
-
There is no ASPError Method for the ASPError object of ASP. Only read-only
properties are available for the ASPError object of ASP. And the properties of
ASPError object of ASP is returned by the Server.GetLastError method.
-
The properties of ASP application object can be grouped into
- Error/Variable: ASPCode; ASPDescription; Category; Description; Number;
- File/Variable: Column; File; Line; Source
Link:http://output.to/sideway/default.asp?qno=120100031 Response Object
Response Object
Response object of ASP is related to sending response from the server to the
client.
Methods
Method |
Description |
AddHeader |
Add and set the HTTP header with "header name" to "value" |
AppendToLog |
Append "a string" to the end of the serer log entry for the HTTP request |
BinaryWrite |
Write or Send "the information" to the HTML output directly without carrying out
any character-set conversion. |
Clear |
Clear the buffered HTML output |
End |
End the interpretation process by stopping
the further processing the .asp file and
returning the completed result to the HTML output |
Flush |
Flush the buffered HTML output by sending the output immediately |
Redirect |
Redirect the HTTP request to "a specified URL" by sending a
moved HTTP header to the client |
Write |
Write "the specified string" to the HTML output |
Properties
Property |
Description |
Buffer |
Set a flag to indicate whether the HTML output is buffered or not |
CacheControl |
Set the value of the Cache-Control header to indicate whether the proxy servers
or other cache mechanism can cache the HTML output |
Charset |
Append the name of character set to the charset parameter to specify the
character encoding for the browser. |
CodePage |
Set the value of code page for the data of response in the intrinsic objects to
specify the character encoding for different languages in the server |
ContentType |
Set the value of content-type header to specify the content type of the HTTP
response |
Cookies (collection) |
Add or set the value of a cookie |
Expires |
Set the length of the time in minutes that the HTML page can be cached on the
browser to calculate the absolute expires time according to the time on the
server for the HTTP Expires header. |
ExpiresAbsolute |
Set the
date and time that the HTML page to be expired on the
browser for the HTTP header |
IsClientConnected |
A read only property to indicate whether the conncection to the server has been
reset by the client or not |
LCID |
Set the value of
LCID for the data of response output to
specify the format of dates, times, and currency for different geographical
locale for the server |
PICS |
Set the value of PICS label for the pics-label header to specify the content
rating. |
Status |
Set the value of the status line returned by the server to the client |
Remarks
The
methods and properties of ASP response object can be grouped into
- Web Server
- ASP Control
- Encoding: CodePage; LCID;
- Buffer control: Buffer; Clear; Flush;
- Stop script processing: End;
- ReadOnly flag: IsClientConnected
- HTTP Header
- Moved to a specified URL: Redirect
- Send a status line: Status
- Add new header: AddHeader
- Set value of standard header: CacheControl; Charset; ContentType;
Expires; ExpiresAbsolute; PICS;
- Set value of Collection: Cookie
- HTML Content
- Direct data Output: BinaryWrite;
- Encoded Output: Write
|
|