Urlpattern some understandings and suggestions on refresh_pattern in squid

Source: Internet
Author: User
The role of Refresh_pattern:
Used to determine how long a page stays in the cache after it enters the cache. The Refresh_pattern rule applies only to responses that do not have a definite expiration date. The original server can use the Expires header, or the Cache-control:max-age directive, to specify the expiration date.
Syntax: Refresh_pattern [-i] regexp min percent max [options]
The min parameter is the number of minutes. It is the minimum time limit for outdated responses. If a response resides in the cache for no longer than the minimum limit, it does not expire. Similarly, the max parameter is the maximum time limit for surviving responses. If a response resides in the cache longer than the maximum limit, it must be refreshed.
The response between the minimum and maximum time limits will face the last modification factor of squid Lm-factor algorithm lm-factor= (response age)/(resource age). For such a response, Squid calculates the age of the response and the last modification factor, and then compares it as a percentage value. The response age is simply the amount of time that is generated from the original server, or after the last validation response. The source age is different between the last-modified and the date header. Lm-factor is the ratio of response age to source age.
The meaning of several commonly used parameters
Override-expire
This option causes Squid to check the Min value before checking the expires head. Thus, a non-zero min time allows squid to return an unconfirmed cache hit, even if the response is ready to expire.
Override-lastmod
The re-election causes Squid to check the Min value before checking the percentage of lm-factor.
Reload-into-ims
This option allows squid to send a request in the confirmation request with the No-cache command. In other words, Squid adds a if-modified-since header to the request before forwarding the request. Note that this only works when the target has a last-modified timestamp. The request that comes in outside keeps the no-cache instruction so that it reaches the original server.
Reload-into-ims can be used in general. It is actually the time-out of the Force control object, which violates the spirit of the HTTP protocol, but in the case of narrow bandwidth, it can improve the apparent system corresponding time.
Example:
Refresh_pattern-i \.css$ 1440 50% 129600 reload-into-ims
Refresh_pattern-i \.xml$ 1440 50% 129600 reload-into-ims
Refresh_pattern-i \.html$ 1440 90% 129600 reload-into-ims-
Refresh_pattern-i \.shtml$ 1440 90% 129600 reload-into-ims
Refresh_pattern-i \.hml$ 1440 90% 129600 reload-into-ims
Refresh_pattern-i \.jpg$ 1440 90% 129600 reload-into-ims
Refresh_pattern-i \.png$ 1440 90% 129600 reload-into-ims
Refresh_pattern-i \.gif$ 1440 90% 129600 ignore-reload
Refresh_pattern-i \.bmp$ 1440 90% 129600 reload-into-ims
Refresh_pattern-i \.js$ 1440 90% 129600 reload-into-ims
Ignore-reload
This option causes Squid to ignore any no-cache instructions in the request.
So. If you want the content to enter the cache will not be deleted, until the active purge off, you can add the ignore-reload option, which we commonly used in mp3,wma,wmv,gif and the like.
Examples:
Refresh_pattern-i \.mp3$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.wmv$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.rm$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.swf$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.mpeg$ 1440 50% 2880 ignore-reload
Refresh_pattern-i \.wma$ 1440 50% 2880 ignore-reload
Resource age = Time the object entered the cache-the last_modified of the object
Response Age = Current time-The time the object entered the cache
Lm-factor= (response Age)/(Resource age)
For example, only percent is considered here, regardless of Min and Max
Example: Refresh_pattern 20%
Suppose the source server www.aaa.com/index.htm-----lastmodified is 2007-04-10 02:00:00
Squid on proxy.aaa.com/index.htm index.htm Enter cache time 2007-04-10 03:00:00
1) If the current time 2007-04-10 03:00:00
Resource age = 3 points-2 points = 60 Minutes
Response age = 0 minutes
Index.htm can also stay at cache time (resource age) *20%=12 minutes
In other words, Index.htm enters the cache, can stay for 12 minutes before being re-confirmed.
2) If the current time 2007-04-10 03:05:00
Resource age = 3 points-2 points = 60 Minutes
Response age = 5 minutes
Index.htm can also stay at cache time (resource age) *20%=12 minutes -5=7
lm-factor=5/60=8.3%<20%
Until 2007-04-10 03:12:00 lm-factor=12/60=20%, the page in the cache index.htm finally stale.
If there is no index.htm request at this time, index.htm will be in the cache, if there is a index.htm request, Squid received the request, because it has expired, Squid will send a index.htm to the source server whether there is a change of request, after the source server received, if the index.htm is not updated, squid will not update the cache, directly put the cached content back to the client, while resetting the object to enter the cache time for the source server to confirm the time, such as 2007-0 4-10 03:13:00, if the page was re-confirmed after this. After resetting, the resource age becomes longer and the corresponding time to survive in the cache becomes longer.
If there is a change, return the latest index.htm to Squid,squid to update the cache, and then return the new index.htm to the client, and recalculate resource age based on the last_modified and time of page fetch in the new page. Further calculate the survival time.
In fact, after a page enters the cache, his survival time is determined, i.e. (resource age) * percent, until it is re-confirmed.

The above describes the Urlpattern on squid refresh_pattern Some of the understanding and suggestions, including the urlpattern aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.