Welcome! Log In Create A New Profile

Advanced

Re: Purge the Nginx cache

All files from this thread

File Name File Size   Posted by Date  
nginxdefault.conf 5.1 KB open | download kaushalshriyan 04/26/2022 Read message
nginxpurge.conf 5.2 KB open | download kaushalshriyan 04/28/2022 Read message
nginxdefault.conf 5.1 KB open | download kaushalshriyan 05/03/2022 Read message
nginx.conf.bypass 5.4 KB open | download kaushalshriyan 05/03/2022 Read message
May 03, 2022 12:22PM
On Tue, May 3, 2022 at 5:30 PM Francis Daly <francis@daoine.org> wrote:

> On Tue, May 03, 2022 at 03:59:48PM +0530, Kaushal Shriyan wrote:
>
> Hi there,
>
> > I am following https://bluegrid.io/edu/how-to-purge-the-nginx-cache/ and
> > have attached the nginx config file for your reference. I am running
> nginx
> > version: nginx/1.20.2 on CentOS Linux release 7.9.2009 (Core)
> >
> > #curl -I https://testnginxproxycachepurge.testintcraft.com -H
> 'Cache-Purge:
> > true'
> > HTTP/1.1 200 OK
> > *X-Cache-Status: HIT*
> >
> > Please guide me. Thanks in advance.
>
> You made a curl request for
> https://testnginxproxycachepurge.testintcraft.com.
>
> Your config for that request (location /) includes
>
> proxy_cache_bypass $bypass;
> proxy_cache_bypass $no_cache $nouricache;
>
> Each of those variables is 0 or empty, so "X-Cache-Status: HIT"
> is correct.
>
> If you want to bypass the cache, you must make at least one of those
> variables have a different value.
>
> For local testing, you could try adding something like
>
> map $http_cache_purge $bypass {
> default 0;
> true 1;
> }
>
> beside your other "map" directives; but you should understand what
> that does, and how it compares to what you want, before running it
> in production.
>
>
>
> If there are follow-up questions, it might be worth explaining what
> exactly it is that you want to achieve.
>
> The "normal" nginx behaviour when caching is enabled, is: a request comes
> from the client; nginx looks in the cache to see if it has a response
> for that that request that is still valid; if there is a valid response,
> nginx writes it to the client; if there is not a valid response, nginx
> makes a request of upstream, gets the response, writes it to the cache
> with a suitable "valid" time, and writes it to the client.
>
> Pretty much every step of that can be changed by configuration.
>
> I *think* that the thing that you want to do is: for some specific
> requests, instead of nginx sending a valid response from its cache,
> nginx should make a request of upstream and write the new response to
> the cache (as well as sending it to the client).
>
> If that is not it -- or if you want to give a more specific description
> of "some specific requests" -- then adding the details will help other
> people to be able to provide a good answer.
>
> Good luck with it,
>
> f
> --
> Francis Daly francis@daoine.org
> _______________________________________________
> nginx mailing list -- nginx@nginx.org
> To unsubscribe send an email to nginx-leave@nginx.org


Thanks Francis for the detailed explanation and much appreciated !!!. We
typically clear the nginx cache manually using the below command.

#rm -rf /var/www/nginx/cache/content/*
#rm -rf /var/www/nginx/cache/files/*

The bigger problem is that this way of purging the Nginx cache deletes
everything that was cached by this Nginx reverse proxy server and adds
overhead to the infrastructure impacting the performance resulting with a
high number of requests per time unit.
I am trying out by purging with the BYPASS method as Nginx module
proxy_cache_purge needs commercial subscription.

Directive proxy_cache_bypass is a recommended approach to refresh the cache
resource after successful retrieval of the contents from the upstream
backend server.

I have deleted the cache by following the method

#rm -rf /var/www/nginx/cache/content/*
#rm -rf /var/www/nginx/cache/files/*
#curl -I https://testnginxproxycachepurge.testintcraft.com -H 'Cache-Purge:
true'
HTTP/1.1 200 OK
Server: nginx/1.20.2
Date: Tue, 03 May 2022 16:06:08 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Cache-Control: max-age=21600, public
Link: https://testnginxproxycachepurge.testintcraft.com/;
rel="canonical", https://testnginxproxycachepurge.testintcraft.com/;
rel="shortlink", https://testnginxproxycachepurge.testintcraft.com/home;
rel="revision"
X-UA-Compatible: IE=edge
Content-language: en
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Permissions-Policy: interest-cohort=()
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Vary: Cookie
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
Set-Cookie:
ADRUM_BT=R%3A0%7Cg%3A39ca00fc-b183-4fbf-95ad-494a6e7b8d1f102%7Cn%3Aicebergtest_e1c60ae6-5d00-47d5-8c0a-690d8465795f%7Ci%3A129601%7Cs%3Af;
expires=Tue, 03-May-2022 16:06:38 GMT; Max-Age=30; path=/
Last-Modified: Tue, 26 Apr 2022 11:42:25 GMT
ETag: "1650973345"
Access-Control-Allow-Origin: *

*X-Cache-Status: MISS*
#curl -I https://testnginxproxycachepurge.testintcraft.com -H 'Cache-Purge:
true'
HTTP/1.1 200 OK
Server: nginx/1.20.2
Date: Tue, 03 May 2022 16:06:19 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Cache-Control: max-age=21600, public
Link: https://testnginxproxycachepurge.testintcraft.com/;
rel="canonical", https://testnginxproxycachepurge.testintcraft.com/;
rel="shortlink", https://testnginxproxycachepurge.testintcraft.com/home;
rel="revision"
X-UA-Compatible: IE=edge
Content-language: en
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Permissions-Policy: interest-cohort=()
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Vary: Cookie
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
Set-Cookie:
ADRUM_BT=R%3A0%7Cg%3A39ca00fc-b183-4fbf-95ad-494a6e7b8d1f102%7Cn%3Aicebergtest_e1c60ae6-5d00-47d5-8c0a-690d8465795f%7Ci%3A129601%7Cs%3Af;
expires=Tue, 03-May-2022 16:06:38 GMT; Max-Age=30; path=/
Last-Modified: Tue, 26 Apr 2022 11:42:25 GMT
ETag: "1650973345"
Access-Control-Allow-Origin: *

*X-Cache-Status: HIT*#

I am seeing it as HIT instead of BYPASS in context to Nginx cache. I am
attaching the config file for your reference. Please comment and I look
forward to hearing from you. Thanks in Advance.

Best Regards,

Kaushal
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Attachments:
open | download - nginx.conf.bypass (5.4 KB)
Subject Author Posted

Purge the Nginx cache

kaushalshriyan April 22, 2022 12:38PM

Re: Purge the Nginx cache

Sergey A. Osokin April 22, 2022 01:02PM

Re: Purge the Nginx cache

kaushalshriyan April 22, 2022 01:32PM

Re: Purge the Nginx cache

Sergey A. Osokin April 22, 2022 01:42PM

Re: Purge the Nginx cache

kaushalshriyan April 22, 2022 01:56PM

Re: Purge the Nginx cache Attachments

kaushalshriyan April 26, 2022 02:02PM

Re: Purge the Nginx cache

kaushalshriyan April 26, 2022 02:28PM

Re: Purge the Nginx cache

Sergey A. Osokin April 26, 2022 04:44PM

Re: Purge the Nginx cache Attachments

kaushalshriyan April 28, 2022 03:30PM

Re: Purge the Nginx cache

kaushalshriyan April 29, 2022 02:20PM

Re: Purge the Nginx cache

kaushalshriyan May 02, 2022 03:10PM

Re: Purge the Nginx cache

Francis Daly May 03, 2022 04:30AM

Re: Purge the Nginx cache Attachments

kaushalshriyan May 03, 2022 06:34AM

Re: Purge the Nginx cache

Francis Daly May 03, 2022 08:02AM

Re: Purge the Nginx cache Attachments

kaushalshriyan May 03, 2022 12:22PM

Re: Purge the Nginx cache

Francis Daly May 04, 2022 09:10AM

Re: Purge the Nginx cache

Tammymeans May 17, 2022 08:27AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 224
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