CacheControl in ASP.NET
5458 단어 asp.net
The CacheControl property allows you to set the HTTP/1.1 Cache-Control header in a response.Syntax
Response.CacheControl [
=
Cache Control Header ]
Parameters
Cache Control Header
The following is a partial list of values supported by the HTTP/1.1 Protocol. Please see the
Hypertext Transfer Protocol -- HTTP/1.1 specification at the
World Wide Web Consortium Web site , section 14.9, for more complete descriptions.
Value
Description
Private
A cache mechanism may cache this page in a Private cache and resend it only to a single client. This is the default value. Most proxy servers will not cache pages with this setting.
Public
Shared caches, such as proxy servers, will cache pages with this setting. The cached page can be sent to any user.
No-cache
Do not cache this page at all, even if for use by the same client.
No-store
The response and the request that created it must not be stored on any cache, whether shared or private. The storage inferred here is non-volatile storage, such as tape backups. This is not an infallible security measure.
Note
Between your Web server and a user requesting your page, there may be proxy servers configured to cache Web pages for faster response times. Usually ASP pages are developed to be unique for each user, or may contain secure information.
For this reason, IIS sets this property to "Private" so that proxy servers or other cache mechanisms will not cache pages. You can override this default value, setting it to any value supported by the HTTP/1.1 protocol, documented in the
Hypertext Transfer Protocol -- HTTP/1.1 specification at the
World Wide Web Consortium Web site .
If there is no cache mechanism between your Web server and a client computer, or if a proxy server is running HTTP/1.0, CacheControl will be ignored.
Setting CacheControl to "public" may seem to improve the performance of your .asp files, but it is discouraged if you generate custom HTML for every request, and a proxy server might interfere with the response.
The values for CacheControl are strings, and must be enclosed in quotation marks (" "). You must set CacheControl before any response is sent to the client unless response buffering is enabled.
Example
CacheControl comes before the tag to ensure that it is set before content is sent to the client.
--- CacheControl_NoBuffer.asp ---
<% Response.Buffer = False Response.CacheControl = "private"%><HTML><HEAD><TITLE>Response.CacheControl Example</TITLE></HEAD><BODY> Output from this page is sent to the client as it is being processed.<BR>It will not be cached.<BR> Today is <%= Date %>, <%= Time %><BR><H3>Please enter your credit card number:</H3><FORM NAME="Order" METHOD="POST" ACTION="order.asp "><INPUT TYPE="TEXT" NAME="CreditCard"><INPUT TYPE="SUBMIT" VALUE="Submit" NAME="Submit"></FORM></BODY></HTML>--- CacheControl_Buffer.asp ---<% Response.Buffer = True %><HTML><HEAD><TITLE>Response.CacheControl Example</TITLE></HEAD><BODY> Output from this page is sent to the client once it is completely processed bythe server, so we can set CacheControl anytime.<BR><% Response.CacheControl = "private" %>It will not be cached.<BR>Today is <%= Date %>, <%= Time %><BR><H3>Please enter your credit card number:</H3><FORM NAME="Order" METHOD="POST" ACTION="order.asp "><INPUT TYPE="TEXT" NAME="CreditCard"><INPUT TYPE="SUBMIT" VALUE="Submit" NAME="Submit"></FORM></BODY></HTML>from:http://www.asp-dev.com/main.asp?page=94
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
작업 중 문제 해결 - (win 2003 asp. net) Session 과 페이지 전송 방법 으로 해결 방안 을 정상적으로 사용 할 수 없습니다.또한 F 는 처음에 우리 의 BP & IT 프로젝트 팀 이 Forms 폼 검증 을 사용 했다 고 판단 할 수 있 습 니 다. 페이지 를 뛰 어 넘 는 것 은http://hr.bingjun.cc/MyTask/MyTas...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.