Quick question on NGINX cache

Alex Evonosky alex.evonosky at gmail.com
Sat May 23 21:04:01 UTC 2020


Disregard, found the issue.

thank you.

On Sat, May 23, 2020 at 4:18 PM Alex Evonosky <alex.evonosky at gmail.com>
wrote:

> "Can you be more specific? Which "cache"? Browser cache? Nginx content
> cache? try_files has nothing to do with caching..."
>
>
> Nginx content cache
>
>
> "Either way, you need to check your headers to ensure that they allow
> caching for said pages. Also if any cookies are being sent then nginx
> won't cache the page."
>
>
> I looked at the headers using CURL..
>
> The issue seems this:
>
>
> The request hits NGINX and the backend server(s) for Wordpress are cached
> just fine from just the FQDN --- example.com
>
> however, if I try to go to say, example.com/?page_id=1234, the headers do
> not show NGINX anymore, as only the servers for Wordpress show up; Almost
> like a
> cache punch-hole.
>
>
> ===== proxy.conf ====
>
> proxy_cache_path /tmp/cache keys_zone=my_cache:10m max_size=10m
> inactive=60m;
>
> #proxy_redirect off;
> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> add_header X-Cache-Status $upstream_cache_status;
> client_max_body_size 10m;
> client_body_buffer_size 128k;
> proxy_connect_timeout 90;
> proxy_send_timeout 90;
> proxy_read_timeout 90;
> proxy_buffers 32 4k;
>
>
>
> ==== nginx.conf ====
>
> http {
>         upstream example.com {
>         least_conn;
>         server 10.10.10.138:8999;
>         server 10.10.10.84:8999;
>         }
>
> server {
> listen 82;
> location / {
> try_files $uri $uri/ /$args /index.php?$args;
> proxy_cache my_cache;
> proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
> proxy_cache_background_update on;
> proxy_pass http://example.com;
> proxy_cache_valid any 60m;
> proxy_cache_methods GET HEAD POST;
> proxy_http_version 1.1;
> proxy_set_header Connection keep-alive;
> proxy_ignore_headers Cache-Control Expires Set-Cookie;
>       }
> }
>
> sendfile on;
> tcp_nopush on;
> tcp_nodelay on;
> keepalive_timeout 65;
> types_hash_max_size 2048;
>
> gzip on;
> gzip_disable "msie6";
>
> # include /etc/nginx/conf.d/*.conf;
> # include /etc/nginx/sites-enabled/*;
> include /etc/nginx/proxy.conf;
>
> }
>
>
>
>
>
> Thank you,
> Alex
>
>
>
>
> On Sat, May 23, 2020 at 8:43 AM J.R. <themadbeaker at gmail.com> wrote:
>
>> > And the main page caches OK, but any page the resides on the "?page_id"
>> is
>> > not getting cached.  Is there more to the "try_files" that needs applied
>> > for caching of these permalinks?
>>
>> Can you be more specific? Which "cache"? Browser cache? Nginx content
>> cache? try_files has nothing to do with caching...
>>
>> Either way, you need to check your headers to ensure that they allow
>> caching for said pages. Also if any cookies are being sent then nginx
>> won't cache the page.
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20200523/8f051847/attachment.htm>


More information about the nginx mailing list