5

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?

Yogendra
  • 101
  • 1
  • 1
  • 7

1 Answers1

5

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

Neurotransmitter
  • 6,289
  • 2
  • 51
  • 38
Christopher Schultz
  • 20,221
  • 9
  • 60
  • 77
  • 2
    The question is about making IE cache the response. You link to a page "How to prevent caching in Internet Explorer", which is the opposite. – R. Schreurs Jun 15 '18 at 14:49