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

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

close

References

  1. Active Server Pages,  
  2. ASP Overview,  
  3. ASP Best Practices,  
  4. ASP Built-in Objects,  
  5. Response Object,  
  6. Request Object,  
  7. Server Object (IIS),  
  8. Application Object (IIS),  
  9. Session Object (IIS),  
  10. ASPError Object,  
  11. ObjectContext Object (IIS),  
  12. Debugging Global.asa Files,  
  13. How to: Debug Global.asa files,  
  14. Calling COM Components from ASP Pages,  
  15. IIS ASP Scripting Reference,  
  16. ASP Keywords,  
  17. Creating Simple ASP Pages,  
  18. Including Files in ASP Applications,  
  19. ASP Overview,  
  20. FileSystemObject Object,  
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  
  22. ADO Fundamentals,  
close

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 7

Culture

Chinese 1097

English 337

Reference 67

Computer

Hardware 149

Software

Application 187

Digitization 24

Numeric 19

Programming

Web 757

CSS 1

ASP.NET 1

Regular Expression 1

HTML

Knowledge Base

Common Color 1

Html Entity (Unicode) 1

Html 401 Special 1

OS 389

MS Windows

Windows10 1

.NET Framework 1

DeskTop 7

Knowledge

Mathematics

Formulas 8

Algebra 20

Number Theory 206

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

Physics

Electric 10

Biology 1

Geography 1


Copyright © 2000-2019 Sideway . All rights reserved Disclaimers last modified on 06 September 2019