Can someone explain me behaviour of IE11?
As I got, all browsers which support Http 1.1 (except some versions with bugs), have support of Cache-Control
header.
I have backend which has Access-Control-Request-Headers
with Cache-Control
and If-Modified-Since
only, so I can't use Expires
or Pragma
.
In my case, IE11 has strange behaviour.
Any directives of Cache-Control
not work for me at all in IE11. IE11 just cache all requests with such headers:
Cache-Control: no-cache
Cache-Control: no-store, no-cache
Cache-Control: no-cache, max-age=0
Cache-Control: no-store, no-cache, max-age=0, must-revalidate
Interesting fact that just adding If-Modified-Since: 0
solves my issue.
Why IE11 (I tried it on many PC) ignores Cache-Control
at all and just caches all data?
Request's Headers:
Accept: */*
Accept-Encoding: gzip, deflate
Access-Control-Request-Headers: cache-control, expires, accept-language, x-website-token, authorization, x-website-config, accept
Access-Control-Request-Method: GET
Cache-Control: no-cache
Content-Length: 0
Host: ----
Origin: ----
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Response's Headers:
access-control-allow-credentials: false
access-control-allow-headers: DNT, User-Agent, X-Website-Token, X-Website-Config, X-Website-Dgp, X-Integration-Id, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type,Range, Accept, Accept-Language, Authorization, DNT
access-control-allow-methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
access-control-allow-origin: *
access-control-expose-headers: X-Pagination-Total-Count, X-Pagination-Page-Count, X-Pagination-Current-Page, X-Pagination-Per-Page
access-control-max-age: 3600
content-type: application/json; charset=UTF-8
date: Sat, 13 Jun 2020 23:01:32 GMT
server: nginx/1.16.1
set-cookie: x-last-referrer=;Domain=-----;Path=/;
x-release-version: 1
First, Internet Explorer supports the HTTP 1.1 Cache-Control header, which prevents all caching of a particular Web resource when the no-cache value is specified by an HTTP 1.1 server.
Second, the Cache-Control HTTP header holds directives (instructions) for caching in both requests and responses. A given directive in a request does not mean the same directive should be in the response.
So, to prevent cache the response resource, we could set the cache-control: no-cache
in response and set the Expires to "-1". Another method, as you said, updates the page via a conditional If-Modified-Since request. More detail information, please check this article: How to prevent caching in Internet Explorer.