问题
I am working on a Rails 4 app that requires serving some static assets under a defined URL. I have removed the digest from the resources as discussed in this thread: Serve compiled javascript and css files from rails app for use in external site
Of course this leaves me with the problem that browsers will cache the resources even though they may have been updated. Currently my file is served with the following HTTP Headers:
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 23 Jan 2020 21:45:51 GMT
Content-Type: text/css
Content-Length: 166134
Last-Modified: Mon, 20 Jan 2020 00:03:46 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "5e24ee62-288f6"
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Cache-Control: public
Accept-Ranges: bytes
My understanding is, that I need to change Expires
/Cache-Control
to an appropriate value (like 8 hours) to make the browser eventually request another version of the resource.
How can I set up my rails config to set a specific cache policy for only these resources?
来源:https://stackoverflow.com/questions/59887924/configure-cache-control-for-specific-static-resource-in-rails