Two important differences between Firefox and IE browser cache

Source: Internet
Author: User
ArticleDirectory
    • Conclusion

After creating a Web service, you usually need to configure two types of cache:

    1. When the website is updated, HTML resources expire immediately so that users who are browsing can get updates quickly.
    2. Set all other resources (examples, CSS, and JavaScript scripts) to expire after a certain period of time.

This cache solution covers two simple rules for HTTP caching
The article mentions some ideas about how to deal with updates.

Now httpwatch 6.0
Firefox is supported. We want to discuss the differences between Firefox and IE in processing cache. the method for setting a long expiration time (the second one above) can still be used directly in Firefox, but configuration 1 is slightly different between the two.

In previous articles
, We divide the first entry:

    • In some cases, the dynamic HTML page needs to be updated from the server immediately for display at any time-or even when the back button is used. For example, the status of the bank account or online order is displayed.
    • Static HTML pages, such as contact, FAQs, Or Site Map pages.Last-modified Response Header
      , Allows the browser to re-verify when needed, you can use the cache.

The rest of this article discusses two important differences that affect HTML page caching in Firefox.

1. Use no-cache to prevent invalid Firefox Cache

You can set the following response header to prevent ie from caching anything:

Cache-control: No-Cache

The page with this response header is not saved in the cache, and IE is always loaded from the server again, even if you use the back button. the following example uses httpwatch to listen to an online store. When we click the back button after submitting the order form, the result is as follows:

 

However, this response header cannot prevent Firefox caching. this means that Firefox will always use the cached page during normal access until it sends a GET request for re-verification. in addition, if you access the page through the back button, Firefox will not access the server again, but simply load it directly from the cache.

How can I disable the cache in Firefox? The answer is simple, but it cannot be switched off. Because Firefox relies on cached copies to "file-> Save as", "ViewSource code"This operation service. However, you can control where the page is cached and the cache entries can be used for display.

 

The following response header prevents persistent caching in Firefox and forces the page to be cached in memory:

Cache-control: No-store

This header also prevents access to the cache page when the backend button is used. It triggers an http get request.

The combination of the two response header values can be expected in IE and Firefox:

Cache-control: No-cache, no-store

The following httpwatch Response Header label is shown:

2. If no expiration time is set for Firefox,

When ie encounters an HTTP response without an Expires header, it considers that the cache entry cannot be used automatically until it is re-verified from the service. because a setting item of the temporary IE File "checks the newer version of the webpage" is "automatic" by default, it is usually a session.

This provides a reasonable way to control the cache of Static HTML content. the new IE will get the latest html version, and the cached version will be used until IE is disabled.

Firefox uses different methods to process missing expires headers. If the last-modified header is affected, it uses an expired retry value specified in the HTTP 1.1 Standard rfc2616:

(Reference Specification :)
In addition, if there is a last-Modified Time Value in the response, the retry expiration value cannot exceed the ratio between the value and the current time interval. Generally, this ratio is set to 10%.

The calculation method is as follows:

Expiration time = Current Time + 0.1 * (time difference between last-modified and now)

 

For example, if the last modification time of your static html file is 100 days ago, the expiration time is 10 days later. The following example shows an httpwatch cache tag without an Expires header page:

Firefox automatically sets the expiration time to 8 days later, because this page has not been modified for about 80 days.

This means that in order to keep your HTML page under control, as we do in two simple rules for HTTP caching
As discussed in the article, you 'd better set an appropriate expires value for your static resources such as HTML, images, and CSS files on your Web server.

Conclusion

To ensure that the cache behavior of IE is consistent with that of Firefox, you should:

    • Always specify an Expires header. General settings-1 Use HTML pages to instantly refresh or set a specific expiration time for other slices, CSS, and Javascript script Resources
    • If you want to force page refresh or even click the background button, SetCache-control: No-cache, no-store

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.