Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE 11 ignoring Cache Control header in response

I am setting Expires filter in web.xml of Tomcat. The header comes correctly in response but still IE is not caching. It is always making the fresh request to Tomcat.

<filter>
<filter-name>ExpiresFilter</filter-name>
<filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class>
<init-param>
<param-name>ExpiresByType image/png</param-name>
<param-value>access plus 2 hours</param-value>
</init-param>

</filter>
<filter-mapping>
        <filter-name>ExpiresFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
</filter-mapping>

Below are the headers from respone

Cache-Control: max-age=7199

Expires: Mon, 14 Nov 2016 16:08:22 GMT

Content-Type: image/png

Transfer-Encoding: chunked

Date: Mon, 14 Nov 2016 14:08:22 GMT

Does anyone know, what am I missing here?

like image 511
Yogendra Avatar asked Nov 14 '16 14:11

Yogendra


People also ask

How do you ignore Cache-Control?

If specified, HTTP request cache-control headers are ignored for caching decisions. This option available under Web Sites > Traffic management > Caching > Edit the service and set the value of 'Ignore Request Headers' to Yes.

How do I disable full header view cache?

When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache. You can then close out of Developer Tools.

Is Cache-Control a request or response header?

Cache-control is an HTTP header used to specify browser caching policies in both client requests and server responses. Policies include how a resource is cached, where it's cached and its maximum age before expiring (i.e., time to live).

How do I set Cache-Control in response header?

If you want to enable Cache-Control for all files, add Header set line outside the filesMatch block. As you can see, we set the Cache-Control header's max-age to 3600 seconds and to public for the listed files.


1 Answers

There is Microsoft's own documentation on cache-control.

Short answer: you have to use Pragma: no-cache, Cache-Control: no-cache and Expires all together.

Update 2019-01-24

The above instructions are for disabling caching, while the answer to being able to force caching can be found in this fine SO answer: Make IE to cache resources but always revalidate

like image 71
Christopher Schultz Avatar answered Oct 13 '22 14:10

Christopher Schultz