OutputCache attribute details 1 Location, outputcache
Directory
OutputCache Concept Learning
OutputCache attributes (1)
OutputCache attribute description 1 Location
Cache location in Web applications:
- Client Caching)
- Proxy Caching)
- Reverse Proxy Caching)
- Web Server Caching)
Location: One of the OutputCacheLocation enumerated values.
Use the value specified by this enumeration. These values determine the cache location of the page output. The default value is Any.
- Any: the output cache can be located on the browser client that generates the request, the proxy server that participates in the request (or Any other server), or the server that processes the request. This value corresponds to the HttpCacheability. Public enumeration value.
- Client: the output cache is located on the browser Client that generates the request. This value corresponds to the HttpCacheability. Private enumeration value.
- Downstream: the output cache can be stored on any HTTP 1.1 cacheable device, except for the source server. This includes the proxy server and the client sending the request.
- None: the output cache is disabled for the requested page. This value corresponds to the HttpCacheability. NoCache enumeration value.
- Server: the output cache is located on the Web Server that processes the request. This value corresponds to the HttpCacheability. Server Enumeration value.
- ServerAndClient: the output cache can only be stored on the source server or the client sending the request. The proxy server cannot cache the response. This value corresponds to a combination of HttpCacheability. Private and HttpCacheability. Server Enumeration values.
Prepare before testing. Create a WebSite and add the following configuration files:
<System. web> <caching> <outputCacheSettings> <outputCacheProfiles> <! -- Name cache configuration name duration cache time (in seconds) enabled specifies that the cache is valid --> <add name = "outputCache60" duration = "60" enabled = "true" varyByParam = "*" location = "Any"/> </outputCacheProfiles> </outputCacheSettings> </caching> <compilation debug = "true"/> </system. web>
Add the following two pages: Default. aspx and Default2.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><%@ OutputCache CacheProfile="outputCache60" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><%@ OutputCache CacheProfile="outputCache60" %>
Any: The output cache can be located on the browser client that generates the request, the proxy server that participates in the request (or any other server), or the server that processes the request.
<add name="outputCache60" duration="60" enabled="true" varyByParam="*" location="Any" />
On the client, the first request is an HTTP status code of 200, and the second request is an HTTP status code of 304.
The first HTTP request and response information is as follows (200 ):
The second HTTP request and response information is as follows (304 ):
We can see that the second request contains the If-Modified-Since and Last-Modified tags in the Request Header:
- When the client sends an HTTP request, it uses the If-Modified-Since tag to return the last modification time of the file that the server told it to the server.
- Because the file has been changed and the time on both sides is inconsistent, the HTTP status code returned by the server is 200, and the full content of the new page is sent.
- The HTTP header tag returned by the server contains Last-Modified, indicating the Last modification time of the client page.
You can also check Cache-control.
In addition, there is no response data from the server in the second response. When multiple clients uniformly request this page, the data returned to the client is consistent, that is, obtained from the server. (PS: This is different from the Client), as follows:
Client: The output cache is located on the browser client that generates the request.
<add name="outputCache60" duration="60" enabled="true" varyByParam="*" location="Client" />
The first data request and response are as follows:
Client Cache. If you click the "back" button in the browser or re-enter the URL in the address bar, the browser obtains the page from the cache in this case. However, if you click "refresh", the cache in the browser becomes invalid and the browser sends a page request. However, when the browser performs a rollback operation, it can read its own cached data. This makes no sense to capture the data. Therefore, the second capture order needs to be:
1. Enter the Default. aspx page for the first time (capture Default. aspx once)
2. Click defa2.2.aspx.
3. Go to the Deafult2.aspx page and click the Default. aspx link on the page to jump back (capture Default. aspx once)
At this time, we captured the real 304 instead of the browser's 304.
The request and corresponding data captured by the second request, such:
It can be seen that the connection between the Client and the server has been disconnected in the Request Header during the second request when the Client is set. There is no operation to request the server, and the response status code is 304, read local cache.
When multiple clients request at the same time, the feedback data is inconsistent, as shown below:
Downstream: The output cache can be stored on any HTTP 1.1 cacheable device, except for the source server. This includes the proxy server and the client sending the request.
<add name="outputCache60" duration="60" enabled="true" varyByParam="*" location="Downstream" />
Personal feelingDownstreamAndClinetSimilar, but there are two small differences:
- The data storage space is different from the data storage mode.
- Cache-Control, Client private, and Downstream public
We continue to capture the following two request and response information in the way of Clinet:
First request and response:
The second request and response are exactly the same as those of clinet, and the data in multiple clients is also different.
None: Disable the output cache for the requested page. This value corresponds to the HttpCacheability. NoCache enumeration value.
<add name="outputCache60" duration="60" enabled="true" varyByParam="*" location="None" />
We continue to capture the two request and response information as follows:
First request and response:
Second request and response:
We can see that the two requests are consistent with the response, and the return status code is 200. The Cache-Control information is no-cache, and no Cache-related tags are included in the response information.
If the values are private, must-revalidate, and max-age, no re-access will be performed. If the value is no-cache, the access will be repeated each time.
Pragma: no-cache, which is the same as Cache-Control: no-cache. Pragma: no-cache is compatible with http 1.0. Cache-Control: no-cache is provided by http 1.1. Therefore, Pragma: no-cache can be applied to http 1.0 and http 1.1, while Cache-Control: no-cache can only be applied to http 1.1.
When multiple client requests are sent, the information displayed on the page is inconsistent.
Server: The output cache is located on the Web server that processes the request. This value corresponds to the HttpCacheability. Server Enumeration value.
<add name="outputCache60" duration="60" enabled="true" varyByParam="*" location="Server" />
Continue to capture the two request and response information as follows:
You can see the HTTP request and response data and set itNoneSimilar, but in the case of multiple clients, the Server data can be consistent, but None is not.
ServerAndClient: The output cache can only be stored on the source server or the client sending the request. The proxy server cannot cache the response. This value corresponds to a combination of HttpCacheability. Private and HttpCacheability. Server Enumeration values.
Continue to capture the two request and response information as follows:
The request is similar to that set to Client, but the data of Clinet in multiple clients is inconsistent, but the ServerAndClient can be consistent under multiple clients.
In conclusion, if you have any questions or understanding errors, please correct them.
|
Any |
Client |
Downstream |
None |
Server |
ServerAndClient |
First Request-status |
200 |
200 |
200 |
200 |
200 |
200 |
IE browser rollback-status |
304 |
304 |
304 |
200 |
200 |
304 |
IE browser A label jump back to status |
304 |
304 |
304 |
200 |
200 |
304 |
F5 refresh-status |
304 |
200 |
200 |
200 |
200 |
304 |
Multiple Clients |
Data Consistency |
Inconsistent Data |
Inconsistent Data |
Inconsistent Data |
Data Consistency |
Data Consistency |
Data Storage Area |
1. Client 2. Proxy 3. Servers |
1. Client |
1. Any HTTP 1.1 cacheable Device 2. Proxy Server 3. Request the client |
None |
1. Server |
1. Server 2. Client |
Author: Sakya bitter monk Source: http://www.cnblogs.com/woxpp/p/3976932.html this article copyright belong to the author and blog park a total, welcome to reprint, but without the author's consent must retain this paragraph of the statement, and in the Article Page clearly given the original connection.
In javascript, the document object has a location attribute. What is the difference between it and the location attribute of the window object?
Window indicates the top-level object in the javaScript level, indicating the browser Window
Document
Represents the entire HTML document. It can be used to access all elements on the page. One is a browser window and the other is a document. If the window does not have a frame, it should be the same. I only know this. For details, refer to this page: www.w3school.com.cn/htmldom/htmldom_reference.asp.
C # I have a New form. It's useless to use the Location attribute and SetBounds method to set its Location.
You need to specify that the FormStartPosition attribute of the child form is Manual as follows:
Form2 f2 = new Form2 ();
F2.StartPosition = FormStartPosition. Manual;
F2.Location = new Point (0, 0 );
F2.Show ();