1

My application is build using EmberJs and is served on Nginx. I am able to set Cache-Control header in response using add_header in nginx.conf

location ~* \.(css|eot|gif|jpe?g|js|png|svg|ttf|woff2?)$ {
          expires max;
          add_header Pragma public;
          add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        }

But this alone doesn't work as request header is set to no-cache. So, browser always goes to backend and doesn't use its cache ever.

Response Headers

cache-control: max-age=315360000
cache-control: public, must-revalidate, proxy-revalidate
expires: Thu, 31 Dec 2037 23:55:55 GMT
pragma: public

Request Headers

Cache-Control: no-cache
Pragma: no-cache

I understand that Cahce-Control in request is causing the problem. But I am not able to find how to set this header with some other value. Does ember build or nginx conf support this?

This is the index.html generated by ember which has links for vendor js and css which are supposed to be reused using cache by browser. enter image description here

codingenious
  • 8,385
  • 12
  • 60
  • 90
  • I'ts neither, it is the browser. [See here](https://stackoverflow.com/questions/14541077/why-is-cache-control-attribute-sent-in-request-header-client-to-server). Especially check the "disable cache" option in Chrome/Firefox Developer tools – Lux Dec 09 '22 at 15:18

0 Answers0