Why can't squid cache-control pages in less than 60 seconds?

Source: Internet
Author: User
I have always hoped to have a cache with the ability to quickly update, because many requirements require that the cache be updated in a timely manner. Using the primary school mathematics method, it is easy to calculate the efficiency that can be improved by caching in 5 seconds. However, in squid, a page cannot be cached for 5 seconds or 59 seconds. 64 seconds is a fuzzy line. If it is lower than the fuzzy boundary, it is missing. I cannot give this

I have always hoped to have a cache with the ability to quickly update, because many requirements require that the cache be updated in a timely manner. Using the primary school mathematics method, it is easy to calculate the efficiency that can be improved by caching in 5 seconds. However, in squIdHowever, a page cannot be cached for 5 seconds or 59 seconds. 64 seconds is a fuzzy line. If it is lower than the fuzzy boundary, it is missing.

I cannot give the exact cause of this problem, because I don't want to spend time reading squid's source code. After a lot of tests, it is estimated that the problem lies in squid's pair of Expires and Cache-Con.TrI cannot explain the cause of ol judgment. Is it a classic logic bug ?.

It's only possible. You don't have to worry about it. The following are my testing results, which are usually called phenomena, combined with a small amount of information on the Internet:

1. The smallest CacheExPires is about 65 seconds. I tested it for 64 seconds, but a foreign player found a penetration phenomenon.

Http://markmail.org/message/fcn2z4ym47svjdMc(It is estimated that it is evil, wear it)

It is mentioned that Squid 2.7.STABLE4 or 3.0.STABLE9 can be used to solve the problem. The test result is invalid, and squid's Change Log does not mention this kind of problem.

2. With Last-ModifiEdThere is no problem with how long the Cache-Control is set on the page. Currently, news.163.com is 30 seconds, no problem. Some friends also mentioned:

Http://blog.csdn.net/ikmb/archive/2009/01/07/3729014.aspx

Therefore, to implement ultra-short cache, add Last-Modified.

######################################## ########################

Fu kai (http: // www.Php-Oa.com) reminder: for the minimum expires value, you can configure the minimum-expiry-parameter in squid-TimeSolution:

Http://www.php-oa.com/2010/03/16/minimum-expiry-time.html

Specifically, add the following sentence to squid. conf:

Minimum_expiry_time 1 seconds

However, this line of configuration may not take effect. In the 2.7.STABLE7 of ubuntu10.04, refresh_pattern will affect it. For example:

Refresh_pattern. 1 80% 60 ignore-reload

Because the min value in refresh_pattern is 1, the minimum expires is still 1 minute and must be changed to 0:

Refresh_pattern. 0 80% 60 ignore-reload

In addition, the time difference between squid and backend machines will also affect the accuracy of the time of each machine. Otherwise, a smaller expires will cause a greater risk of penetration.

######################################## ########################

3. In the squid configuration file, refresh_pattern is measured in minutes. The minimum value is zero minutes, and the second value is one minute. Therefore, this configuration can load the cache to 60 seconds.

4. Cache-Control for 60 seconds can be cached on some squids, but it needs to be refreshed several times ......

5. When two squids are connected together, one squid cannot Cache-Control for 60 seconds, but the other one can. The difference is that the latter one carries a large number of requests.

6. It was not caused by cache_replacement_policy.

7. It was not caused by refresh_patterns.

8. Other options may fail to change this situation instantly ...... I am confident that the configuration is not controllable. This is a bug and will be solved by the open-source community.

I am also frustrated with these test results. I had hoped squid3.0 could solve this problem, so there could be a high-sounding reason for installing 3.0. Currently, I still use 2.7 For squid3.0, 2.6, 2.5, and 2.5, but it is really difficult to find out why I can say that I want to upgrade my team? This is a great failure of squid.

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.