What does Meta Expires and Pragma mean

Prevent caching in Internet Explorer

  • 5 reading time

Important

The Internet Explorer 11 desktop application will be retired and will no longer be supported on June 15, 2022 (see FAQ for a list of areas). The same IE11 apps and websites that you use today can open Microsoft Edge in Internet Explorer mode. Here you can get more information.

This article describes how to use HTTP headers to control webpage caching in Internet Explorer.

Original product version: Internet Explorer
Original KB number:   234067

Summary

You can use Microsoft Internet Information Server (IIS) to mark very volatile or sensitive pages at the very beginning of specific Active Server Pages (ASP) pages with the following script:

Expiration and the Expires header

It is strongly recommended that all web servers use a scheme for running all web pages. It is a bad practice when a web server did not dump expiration information back to requesting clients via the HTTP Expires response header for each resource. Most browsers and advanced proxies respect this flow information and use it to increase the efficiency of communication over the network.

Always use the Expires header to indicate the most sensible time when a particular file on the server needs to be updated by the client. If pages are updated regularly, the next update period is the most efficient answer. For example, let's take a daily news page on the Internet that is updated every day at 5:00 a.m. The web server for this news page should return an Expires header with a value for 5:00 AM. On the next day. Once this has happened, the browser does not need to contact the web server again until the page has changed.

Pages that should not be changed should be marked with an expiration date of approximately one year.

In many cases, web servers have one or more volatile pages on a server that contain information that can be changed immediately. These pages should be marked by the server with the value "-1" for the Expires header. Typically, on future user requests, Internet Explorer will contact the web server via an If-Modified-Since conditional request to receive updates for that page. However, the page remains in the disk cache (Temporary Internet Files). And the page is used in appropriate situations without contacting the remote web server, e.g. B .:

  • when the BACK and FORWARD buttons are used to access navigation history.
  • when the browser is in offline mode.

The Cache-Control header

However, certain pages are so changeable or confidential that they do not have to be stored temporarily. Internet Explorer supports the HTTP 1.1 Cache-Control header for this purpose. This header prevents the caching of a specific web resource when the cached value is provided by an HTTP 1.1 server.

Pages that are held out of the cache are not available until the browser can reconfigure the web server. Therefore servers should use the cache control. In most cases, Expires: -1 is preferred.

The Pragma: No-Cache header

Unfortunately, older HTTP 1.0 servers can use cache control. For backward compatibility with HTTP 1.0 servers, Internet Explorer supports a special use of the HTTP pragma: no cache header. If the client is communicating with the server over a secure connection () and the server returns a Pragma: no-cache header with the response, Internet Explorer will not cache the response.

However, the Pragma: no-cache header was not for this purpose. According to the Http 1.0 and 1.1 specifications, this header is only defined in the context of a request, not a response. It is intended for proxy servers that may prevent certain critical requests from reaching the destination web server. In future applications, cache control is the right way to control caching.

HTTP-EQUIV META tags

HTML pages enable a special HTTP EQUIV form of the META tag, which specifies certain HTTP headers from the HTML document. Here is a quick sample HTML page using Pragma: no-cache and Expires: -1:

Pragma: No cache prevents caching only when used over a secure connection. A Pragma: no-cache META tag is treated identically to Expires: -1 if used in a non-secure page. The page is cached but marked as expired immediately.

Cache-Control META HTTP-EQUIV tags are ignored and have no effect in Internet Explorer, version 4 or 5. To be able to use Cache-Control, this header must be specified using HTTP headers, as described in Cache-Control.

Note

The use of standard HTTP headers is broadly preferred over META tags. META tags usually need to be displayed in the HTML HEAD SECTION above. And there is at least one known problem with the HTTP-EQUIV META tag pragma.

Server options for caching

If Cache-Control needs to be used on non-ASP pages, you may need to use options in the server configuration to add this header automatically. For information on adding HTTP headers to server responses for a specific directory, see the Server document. For example, in IIS 4, do the following:

  1. Start the IIS manager.
  2. In the Computers and Services tree, open the default web server or the web server. Find the directory that contains the content that the cache control needs.
  3. Open that Properties dialog box for this directory.
  4. Choose the HTTP Headers tab out.
  5. Choose the button In the Custom HTTP Headers group, add and add Cache-Control for the header name, not a cache for the header value.

It is not good to use this header globally across the web server. Limit use to content that absolutely cannot be cached on the client.

Checklist for problems

If you've used the techniques in this article and are still having problems with caching and Internet Explorer, read this step-by-step checklist before you contact Microsoft for technical assistance:

  • Are you using the cache control with the ASP property or via a returned HTTP header? This is the only way to really prevent Internet Explorer caching.
  • Are you using Internet Explorer 4.01 Service Pack 2 or higher? There is no way to completely prevent caching in previous versions of the browser.
  • Did you double check that http 1.1 is enabled on your web server and are returning http 1.1 responses to Internet Explorer? Cache-Control headers are not valid in HTTP 1.0 responses.
  • If you are using CGI / ISAPI / Servlets on the server side, do you follow the HTTP 1.1 specification closely, especially for terminating # A0 with CRLF? In the interest of performance, Internet Explorer typically does not forgive responses that violate the HTTP 1.1 specification. This usually results in ignored headers or reports of unexpected server errors.
  • Are the HTTP headers spelled correctly?

Sources of information

For more information on HTTP / 1.1, see RFC 2616.