Welcome! Log In Create A New Profile

Advanced

Allow caching of *some* filetypes?

Posted by mevans336 
mevans336
Allow caching of *some* filetypes?
December 22, 2016 02:30PM
For security purposes, we utilize the Cache-Control "no-cache, no-store,
must-revalidate" add_header parameter in our root location block.

However, I'd like to tweak this to allow the following file types to be
cached: jpg|jpeg|png|gif|ico|js|css|html

I added this above my root location / block, but it breaks all images and
our css as well.

location ~* \.(jpg|jpeg|png|gif|ico|js|css|html)$ {
expires 7d;
}

Here is our root location block also:

location / {

add_header X-Frame-Options SAMEORIGIN;
add_header Strict-Transport-Security
max-age=63072000;
add_header Cache-Control "no-cache, no-store,
must-revalidate";
add_header Pragma "no-cache";
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_read_timeout 120s;
proxy_next_upstream error timeout invalid_header
http_404 http_500;
proxy_intercept_errors on;
proxy_pass http://my_proxy;
}

Am I doing this correctly?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271676,271676#msg-271676

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
mevans336
Re: Allow caching of *some* filetypes?
December 22, 2016 03:00PM
I figured it out. I just needed to add the proxy+pass in the new location
block.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271676,271677#msg-271677

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login