We have seen in several places how ASPs Create or modify the HTTP headers that are sent to the customer in response to a page request. There are several properties and methods in the response object that can help us do a little. Here are some header methods:
· Controls caching and expiration.
· Creates a state and a custom HTTP header.
· Specifies the MIME type or content type.
· Add a Pics label.
The next step is to study each aspect briefly. On the Response Object home page (show_response.asp), click the related property name or method name to check the properties and methods that we are talking about.
1. Cache and "Expiration" ASP Web pages
Users ' browsers, as well as their any proxy servers with servers, can cache HTML and Web pages created with ASP. When the user subsequently requests the page, the browser sends a "last modified" request to the server (using a http_if_modified_since header that contains the date of the cached version) to ask if the page has been modified.
If it is not modified, the server applies the status code and the message "304 not Modified" to respond, the browser will use the cached content instead of downloading a copy over the network. If a modified version already exists, it is sent with the "OK" status code and the message.
1) Response.cachecontol Property
Other factors can also affect the process. However, any proxy server within the network route used by the Web page (typically located on the client side) can be discarded by setting the Response.CacheControl property as private to discard the cached Web page. This is the default for ASP Web pages in ASP 3.0 and is not set. This is especially useful when web pages are specially tailored for individual visitors. This can prevent other users on the same network from entering the same Web page. Allows the server to cache Web pages when the CacheControl property value is set to public. Note that some proxy servers may behave differently, or ignore or bypass the header.
In IE4, it is possible to get a false "this page has expired" message when the proxy server cache is available. We have provided a Web page (expiretest_form.asp) that can be tested on the network through its own proxy server to check the impact of this property. You can click Response in the Response Object home page. CacheControl "link to display this page. As shown in the following illustration:
When this page is submitted to the Expiretest_result.asp Web page, you can set the Response.CacheControl property, and then insert the value in the Web page and the time the script was executed:
<%
If Request.Form(“public”) = “on” Then ‘Cache-Control check box was ticked
Response.CacheControl = “Public”
Else
Response.CacheControl = “Private”
End If
%>
<HTML>
...
Cache-Control is: <B><% = Response.CacheControl %></B><P>
Value in text box is: <B><% Response.Write Request.Form(“textbox”) %>
<%
Response.Write Right(“0” & Hour(Now),2) & “:” & Right(“0” & Minute(Now),_
& 2) & “:” & Right(“0” & Second(Now),2)
%></B>
You can see whether the code executes automatically or uses a cached copy by clicking Back and Forward on the browser.