Welcome! Log In Create A New Profile

Advanced

Caching - Always MISS

Posted by Lowie 
Caching - Always MISS
December 28, 2016 05:55PM
Hi all,

I'm having trouble setting up caching. The goal is to have static files cached by NGINX.
The problem is that I always see this in Chrome Devtools: 'x-proxy-cache:MISS'
This is the full response headers:

accept-ranges:bytes
cache-control:max-age=2592000
cache-control:public
content-length:9415
content-type:application/javascript
date:Wed, 28 Dec 2016 22:40:23 GMT
etag:W/"24c7-159448ae422"
expires:Fri, 27 Jan 2017 22:40:23 GMT
last-modified:Wed, 28 Dec 2016 08:27:50 GMT
pragma:public
status:200
x-proxy-cache:MISS


This is part of my config in sites-enabled:

proxy_cache_path /tmp/nginx levels=1:2 keys_zone=my_zone:10m inactive=60m;

server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
ssl on;

server_name example.com

location ~* \.(?:ico|css|js|gif|jpe?g|png|woff|ttf|otf|svg|woff2|eot)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
proxy_cache my_zone;
#proxy_cache_bypass $http_cache_control;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_buffering on;
proxy_ignore_headers "Set-Cookie";
proxy_hide_header "Set-Cookie";
proxy_pass http://localhost:3000;
}

}


I have made www-data owner of /tmp/nginx and changed chmod to 755.
As you can see, I Googled about this and tried adding things people recommended. Such as enabling buffering, ignoring Set-Cookie etc.

What is causing this?

I have another location / block to proxy_pass everything. If I get this working, I intended to move this inside that same block by using an 'if'...



Edited 1 time(s). Last edit at 12/28/2016 05:56PM by Lowie.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 143
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready