File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,11 @@ How it's different to `expires max;`:
3232* Sends ` Expires ` only when it's really necessary, e.g. when a client is requesting resources over ` HTTP/1.0 `
3333* Sets ` public ` attribute to ensure the assets can be cached by public caches, which is typically a desired thing.
3434
35- Thus in most cases, ` immutable on; ` can be used as as a better alternative to ` expires max; ` .
35+ Thus, in most cases, ` immutable on; ` can be used as a better alternative to ` expires max; ` .
3636
3737## Installation
3838
39- ### CentOS/RHEL 6, 7, 8
39+ ### CentOS/RHEL 6, 7, 8; Amazon Linux 2; Fedora Linux
4040
4141 sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
4242 sudo yum -y install nginx-module-immutable
Original file line number Diff line number Diff line change @@ -89,9 +89,8 @@ static ngx_int_t
8989ngx_http_immutable_filter (ngx_http_request_t * r )
9090{
9191 ngx_http_immutable_loc_conf_t * conf ;
92- ngx_table_elt_t * e , * cc , * * ccp ;
92+ ngx_table_elt_t * e , * cc ;
9393 size_t len ;
94- ngx_uint_t i ;
9594
9695 conf = ngx_http_get_module_loc_conf (r , ngx_http_immutable_module );
9796
@@ -125,7 +124,34 @@ ngx_http_immutable_filter(ngx_http_request_t *r)
125124 e -> value .len = len - 1 ;
126125 e -> value .data = (u_char * ) "Thu, 31 Dec 2037 23:55:55 GMT" ;
127126 } else {
127+ #if defined(nginx_version ) && nginx_version >= 1023000
128+ cc = r -> headers_out .cache_control ;
128129
130+ if (cc == NULL ) {
131+
132+ cc = ngx_list_push (& r -> headers_out .headers );
133+ if (cc == NULL ) {
134+ e -> hash = 0 ;
135+ return NGX_ERROR ;
136+ }
137+
138+ r -> headers_out .cache_control = cc ;
139+ cc -> next = NULL ;
140+
141+ cc -> hash = 1 ;
142+ ngx_str_set (& cc -> key , "Cache-Control" );
143+
144+ } else {
145+ for (cc = cc -> next ; cc ; cc = cc -> next ) {
146+ cc -> hash = 0 ;
147+ }
148+
149+ cc = r -> headers_out .cache_control ;
150+ cc -> next = NULL ;
151+ }
152+ #else
153+ ngx_table_elt_t * * ccp ;
154+ ngx_uint_t i ;
129155 ccp = r -> headers_out .cache_control .elts ;
130156
131157 if (ccp == NULL ) {
@@ -158,7 +184,7 @@ ngx_http_immutable_filter(ngx_http_request_t *r)
158184
159185 cc = ccp [0 ];
160186 }
161-
187+ #endif
162188
163189 /* 10 years */
164190 ngx_str_set (& cc -> value , "public,max-age=31536000,immutable" );
You can’t perform that action at this time.
0 commit comments