polr icon indicating copy to clipboard operation
polr copied to clipboard

nginx caching

Open columbian-chris opened this issue 4 years ago • 0 comments

I can't get nginx to cache GET requests to the API for some reason. Here's my conf:

fastcgi_cache_path /var/www/sites/mysite/cache levels=1:2 keys_zone=MYCACHE:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";

upstream php {
    server unix:/var/run/php/php7.3-fpm.sock;
    server 127.0.0.1:9000;
}

server {

        listen 443 ssl http2; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/mysite/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/mysite/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

        root         /var/www/sites/mysite/polr/public;
        index        index.php index.html index.htm;
        server_name  example.com;

        location / {
                try_files $uri $uri/ /index.php$is_args$args;
                # rewrite ^/([a-zA-Z0-9]+)/?$ /index.php?$1;
        }

        location ~ \.php$ {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;

                fastcgi_pass    php;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param   HTTP_HOST $server_name;
                fastcgi_cache   MYCACHE;
                fastcgi_cache_valid 200 60m;
                fastcgi_cache_lock on;
                add_header X-FastCGI-Cache $upstream_cache_status;
        }

}

I can get HIT's if I take out the SCRIPT_FILENAME parameter, but then it doesn't return any data.

Anybody know what I can do to make my Polr site with nginx start caching?

columbian-chris avatar Feb 21 '20 20:02 columbian-chris