Welcome! Log In Create A New Profile

Advanced

Re: Quick question on NGINX cache

Alex Evonosky
May 23, 2020 06:58PM
Jore-

I applied the proxy_hide_header for no-cache headers to NGINX can process
it and cache it.

On Sat, May 23, 2020 at 5:17 PM Jore <community@thoughtmaybe.com> wrote:

> Hi Alex/all,
>
> How did you fix?
>
> I've got a very similar issue.
>
> nginx running Wordpress with the Hypercache plugin but only the homepage
> is cached, other pages "miss" according to page headers.
>
> Thanks,
> Jore
>
>
> On 24/5/20 7:04 am, Alex Evonosky wrote:
>
> Disregard, found the issue.
>
> thank you.
>
> On Sat, May 23, 2020 at 4:18 PM Alex Evonosky <alex.evonosky@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@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@nginx.org
>>> http://mailman.nginx.org/mailman/listinfo/nginx
>>>
>>
> _______________________________________________
> nginx mailing listnginx@nginx.orghttp://mailman.nginx.org/mailman/listinfo/nginx
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Quick question on NGINX cache

Alex Evonosky May 22, 2020 09:32PM

Re: Quick question on NGINX cache

J.R. May 23, 2020 08:44AM

Re: Quick question on NGINX cache

Alex Evonosky May 23, 2020 04:20PM

Re: Quick question on NGINX cache

Alex Evonosky May 23, 2020 05:06PM

Re: Quick question on NGINX cache

Jore May 23, 2020 05:18PM

Re: Quick question on NGINX cache

Alex Evonosky May 23, 2020 06:58PM

Re: Quick question on NGINX cache

Jore May 24, 2020 03:08PM

Re: Quick question on NGINX cache

Jore May 27, 2020 11:22PM

Re: Quick question on NGINX cache

Francis Daly May 28, 2020 08:28AM

RE: Re: Quick question on NGINX cache

Anonymous User May 23, 2020 05:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 155
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready