Sideway
output.to from Sideway





Draft for Information Only

Content

Response Object
 Response.CacheControl Property
   Syntax:
   Parameters:
   Remarks:
   Examples:

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

ValueDescription
publicTo specify the response can be cached by a shared caches and to indicate that the responses can be sent to any client
privateDefault 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-cacheTo 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-storeTo 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-revalidateTo 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-revalidateTo 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-transformTo 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-extensionTo 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

    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.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


©sideway
close

References

  1. Active Server Pages, http://msdn.microsoft.com/en-us/library/aa286483.aspx, updated 20Dec2012
  2. ASP Overview, http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx, updated 21Dec2012
  3. ASP Best Practices, http://technet.microsoft.com/en-us/library/cc939157.aspx, updated 15Apr2013
  4. ASP Built-in Objects, http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx, updated 20Dec2012
  5. Response Object, http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx, updated 20Dec2012
  6. Request Object, http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx, updated 20Dec2012
  7. Server Object (IIS), http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx, updated 20Dec2012
  8. Application Object (IIS), http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx, updated 20Dec2012
  9. Session Object (IIS), http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx, updated 20Dec2012
  10. ASPError Object, http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx, updated 20Dec2012
  11. ObjectContext Object (IIS), http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx, updated 20Dec2012
  12. Debugging Global.asa Files, http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx, updated 15Apr2013
  13. How to: Debug Global.asa files, http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx, updated 15Apr2013
  14. Calling COM Components from ASP Pages, http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx, updated 15Apr2013
  15. IIS ASP Scripting Reference, http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx, updated 15Apr2013
  16. ASP Keywords, http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx, updated 15Apr2013
  17. Creating Simple ASP Pages, http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx, updated 15Apr2013
  18. Including Files in ASP Applications, http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx, updated 15Apr2013
  19. ASP Overview, http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx, updated 15Apr2013
  20. FileSystemObject Object, http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx, updated 14Mayr2013
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx, ADO Object Model, updated 15Apr2013
  22. ADO Fundamentals, http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx, updated 14Mayr2013
close

ID: 120100033 Last Updated: 2/2/2012 Revision: 1 Ref:

IMAGE

Home (5)

Business

Management

HBR (3)

Information

Recreation

Hobbies (7)

Culture

Chinese (1097)

English (336)

Reference (66)

Computer

Hardware (149)

Software

Application (187)

Digitization (24)

Numeric (19)

Programming

Web (644)new

CSS (SC)

ASP.NET (SC)

Regular Expression (SC)

HTML

Knowledge Base

Common Color (SC)

Html Entity (Unicode) (SC)

Html 401 Special (SC)

OS (389)new

MS Windows

Windows10 (SC)

.NET Framework (SC)

DeskTop (7)

Knowledge

Mathematics

Formulas (8)

Number Theory (206)

Algebra (20)

Trigonometry (18)

Geometry (18)

Calculus (67)

Complex Analysis (21)

Engineering

Tables (8)

Mechanical

Mechanics (1)

Rigid Bodies

Statics (92)

Dynamics (37)

Fluid (5)

Fluid Kinematics (5)

Control

Process Control (1)

Acoustics (19)

FiniteElement (2)

Biology (1)

Geography (1)

Latest Updated Links

Copyright © 2000-2019 Sideway . All rights reserved Disclaimers last modified on 10 Feb 2019