You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Sets `immutable` attribute, e.g. `Cache-Control: public,max-age=31536000,immutable` for improved caching
44
+
* Sets `immutable` attribute, e.g. `Cache-Control: public,max-age=31536000,immutable` for improved caching.
45
+
That is 1 year and not 10 years, see why below.
32
46
* Sends `Expires` only when it's really necessary, e.g. when a client is requesting resources over `HTTP/1.0`
33
47
* Sets `public` attribute to ensure the assets can be cached by public caches, which is typically a desired thing.
34
48
35
-
Thus, in most cases, `immutable on;` can be used as a better alternative to `expires max;`.
49
+
Due to the [lacking support of `immutable`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#browser_compatibility) in Chromium-based browsers,
50
+
we also add `stale-while-revalidate=31536000,stale-if-error=31536000` which helps to improve cache hit-ratio in edge cases.
51
+
Use of these directives allows serving cached responses beyond their cache lifetime, which is forever in case of immutable resources.
52
+
53
+
Thus, in most cases, `immutable on;` can be used as a better alternative to `expires max;` to implement the cache-busting pattern.
54
+
55
+
### Why 31536000 seconds (1 year?)
56
+
57
+
The [RFC](https://www.ietf.org/rfc/rfc2616.txt) defines to use one year to make a response as "never expires":
58
+
59
+
> To mark a response as “never expires,” an origin server sends an
60
+
> Expires date approximately one year from the time the response is
61
+
> sent. HTTP/1.1 servers SHOULD NOT send Expires dates more than one
62
+
> year in the future.
63
+
64
+
More details in [the article](https://ashton.codes/set-cache-control-max-age-1-year/).
36
65
37
66
## Installation
38
67
39
-
### CentOS/RHEL 6, 7, 8; Amazon Linux 2; Fedora Linux
68
+
GetPageSpeed provides packaging of the `nginx-module-immutable` in its repositories, as part of its [NGINX Extras](https://nginx-extras.getpagespeed.com/) package collection.
The installation requires a [subscription](https://www.getpagespeed.com/repo-subscribe) for all the operating systems listed, except Fedora Linux, for which it is free.
80
+
81
+
### How to install
82
+
83
+
For any OS listed above, installation steps are the same:
0 commit comments