Behavior status and reload_into_ims option in squid, reload

Source: Internet
Author: User

Behavior status and reload_into_ims option in squid, reload

[Problem]

Proxy Environment Data Stream: local browser -- Proxy Server (squid) -- remote server (RS)

After squid3 is configured for caching, ie cannot obtain the cached data in squid.


To solve this problem, you need a lot of extended knowledge, as shown below:


1. X-Cache and X-Cache-Lookup values

The two values in the HTTP message header of the browser can be used to determine the data cache. HIT indicates that the cache hits, and MISS indicates that the cache is not HIT.

The X-Cache value indicates whether the value obtained by the local browser is the cached data on squid.

The value of X-Cache-Lookup indicates whether the squid caches the data.


After the Cache settings are made on squid3, both X-Cache and X-Cache-Lookup have been hit by Chrome or Firefox.

In IE, X-Cache is not hit, and X-Cache-Lookup is hit.

This indicates that this data has been cached on the server, but the data obtained by IE is not the cached data on squid but the raw data on RS.

For more information, see the second question.


2. Expires/Cache-Control Header and Last-Modified/If-Modified-Since and ETag/If-None-Match

There are too many of these two items. Let's simplify them:

Expires/Cache-Control Header: controls whether the browser caches data directly from the browser or resends the request to the server for data.

Last-Modified/If-Modified-Since and ETag/If-None-Match: the browser sends a request to the server and determines whether the file has been Modified, if no modification is made, only one 304 request is sent back to the browser, notifying the browser to directly retrieve data from its local cache. If yes, the whole data will be sent to the browser again.

To understand these concepts, let's look at 3rd very important understanding questions:


3. Local browser -- Proxy Server (squid) -- remote server (RS)

In this data stream, let's think about how it works. The local Browser needs to obtain the data on a url and then send the HTTP request to squid, squid converts the HTTP request into its own request and sends it to RS. Then squid gets the data and returns the data to the local browser. Therefore, we need to clarify the following important concepts:

1. for RS, the access to RS is squid, which is not directly associated with the local browser.

2. for squid, if the HTTP request returns 304, squid will obtain the cached data from itself. If the HTTP request returns 200, squid will obtain new data from RS.

3. for a local browser, if HTTP returns 304, the data I obtain is the data cached by squid. If the result is 200, it indicates that the data is the new data obtained by squid from RS, and then passed to me, which is equivalent to a new data.


If you understand the above behaviors, you can check the following 4th questions:


4. browser refresh

Different browsers send different headers for refreshing behaviors. Assume that the last time the server returns Last_Modified and ETag.

Ie Refresh: Send If-Modified-Since, If-None-Match, and no Cache-Control value.
Chrome Refresh: If-Modified-Since is sent, If-None-Match is sent, and the Cache-Control value is max-age = 0.
Firefox Refresh: Send If-Modified-Since, If-None-Match, and the Cache-Control value is max-age = 0.
Opera Refresh: If-Modified-Since is not sent, If-None-Match is sent, and the Cache-Control value is no-cache.
Safari Refresh: If-Modified-Since is not sent, If-None-Match is sent, and the Cache-Control value is max-age = 0.


Back to our initial question:

1. after IE refresh, The sent HTTP message header does not contain the cache-control value. Therefore, the HTTP message header does not indicate whether the cache is obtained locally or remotely. The HTTP header is sent to squid as its HTTP message header.

2. In this case, squid will retrieve the latest data from RS regardless of whether the data is cached or not, and then pass it to IE. The cache fails.

3. Although IE sends If-Modified-Since and If-None-Match, you can determine whether to obtain the cache. However, squid cannot use the cache because of the cache-control value.


[Solution]

Reload_assist_ims on (off by default)

In the squid configuration file, enable this option and solve the problem.

Reload_assist_ims refers to converting the no-cache or reload request in the client's HTTP request into If-Modified-Since, so that you can determine whether the file is modified, data transmission between squid and RS only verifies whether the file is updated or changed. If the RS returns a file that has not been changed, it will be directly returned to the client by the squid cache file. If the file is changed, go to the RS to obtain the latest file and cache it, for the next cache usage.

We can see that this option corresponds to the most opera solution.

Although reload_assist_ims only indicates that the no-cache problem can be solved, the problem of no-cache-control can be solved in the actual test process, so the problem of IE is also solved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.