# How to delete cache based on expires headers?

**URL:** <https://www.ruby-forum.com/t/how-to-delete-cache-based-on-expires-headers/238137>\
**Category:** NGINX\
**Created:** [December 19, 2013, 5:21am UTC](https://www.ruby-forum.com/t/how-to-delete-cache-based-on-expires-headers/238137 "2013-12-19T05:21:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [December 19, 2013, 5:21am UTC](https://www.ruby-forum.com/t/how-to-delete-cache-based-on-expires-headers/238137/1 "2013-12-19T05:21:26Z")

</div>

Hi

I’m using proxy\_cache to mirror my files with the configuration below

proxy\_cache\_path /var/cache/nginx/image levels=1:2 keys\_zone=one:10m  
inactive=7d max\_size=100g;

Our backend server has the expires header set to 600secs

Is that posibble for us to also delete the cache files located  
at/var/cache/nginx/image depends on the backend expire header?

---

<div class="post-metadata">

**Author:** ![Indo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/ce7236/32.png) [@Indo\_P](https://www.ruby-forum.com/u/Indo_P)\
**Post date:** [December 24, 2013, 3:58am UTC](https://www.ruby-forum.com/t/how-to-delete-cache-based-on-expires-headers/238137/2 "2013-12-24T03:58:39Z")

</div>

Hello…

Can somebody help me on this?

Thank you before

On Thursday, December 19, 2013 11:21 AM, Indo P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

Hi

I’m using proxy\_cache to mirror my files with the configuration below

proxy\_cache\_path /var/cache/nginx/image levels=1:2 keys\_zone=one:10m  
inactive=7d max\_size=100g;

Our backend server has the expires header set to 600secs

Is that posibble for us to also delete the cache files located  
at/var/cache/nginx/image depends on the backend expire header?

---

<div class="post-metadata">

**Author:** ![Indo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/ce7236/32.png) [@Indo\_P](https://www.ruby-forum.com/u/Indo_P)\
**Post date:** [December 24, 2013, 4:20pm UTC](https://www.ruby-forum.com/t/how-to-delete-cache-based-on-expires-headers/238137/3 "2013-12-24T16:20:51Z")

</div>

Using change de name the file or change size file.

Regards,

---

<div class="post-metadata">

**Author:** ![Indo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/ce7236/32.png) [@Indo\_P](https://www.ruby-forum.com/u/Indo_P)\
**Post date:** [December 30, 2013, 5:28am UTC](https://www.ruby-forum.com/t/how-to-delete-cache-based-on-expires-headers/238137/4 "2013-12-30T05:28:32Z")

</div>

Hi

Is that means that nginx will put the files based on the upstream expire  
headers? After that nginx will delete the cache files?

On Tuesday, December 24, 2013 10:28 PM, Antnio P. P. Almeida  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Why you want to do this? nginx can manage expiration/cache-control  
headers all by itself.

As soon as the defined max-age is set it returns a upstream status of  
EXPIRED until it fetches a fresh  
page from upstream.

Deleting won’t buy you anything in terms of content freshness.

----appa

On Tue, Dec 24, 2013 at 3:57 AM, Indo P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Hello…

---

<div class="post-metadata">

**Author:** ![Indo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/ce7236/32.png) [@Indo\_P](https://www.ruby-forum.com/u/Indo_P)\
**Post date:** [December 24, 2013, 4:28pm UTC](https://www.ruby-forum.com/t/how-to-delete-cache-based-on-expires-headers/238137/5 "2013-12-24T16:28:26Z")

</div>

Why you want to do this? nginx can manage expiration/cache-control  
headers  
all by itself.

As soon as the defined max-age is set it returns a upstream status of  
EXPIRED until it fetches a fresh  
page from upstream.

Deleting won’t buy you anything in terms of content freshness.

----appa

---

<div class="post-metadata">

**Author:** ![Indo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/ce7236/32.png) [@Indo\_P](https://www.ruby-forum.com/u/Indo_P)\
**Post date:** [January 2, 2014, 8:19pm UTC](https://www.ruby-forum.com/t/how-to-delete-cache-based-on-expires-headers/238137/6 "2014-01-02T20:19:32Z")

</div>

Yes.

Nginx will obey the Cache-Control/Expire headers. It won’t delete, but  
it  
will refresh the files so that the served content is fresh.  
So it is as if the files were deleted. AFAIK deletion happens more often  
when the file is not accessed for given time specified through the  
inactive  
parameter of the proxy\_cache\_path/fastcgi\_cache\_path directives.

----appa

---

<div class="post-metadata">

**Author:** ![Indo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/ce7236/32.png) [@Indo\_P](https://www.ruby-forum.com/u/Indo_P)\
**Post date:** [January 6, 2014, 5:18am UTC](https://www.ruby-forum.com/t/how-to-delete-cache-based-on-expires-headers/238137/7 "2014-01-06T05:18:17Z")

</div>

Thanks that makes clear!

On Friday, January 3, 2014 2:19 AM, Antnio P. P. Almeida  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Yes.

Nginx will obey the Cache-Control/Expire headers. It won’t delete, but  
it will refresh the files so that the served content is fresh.  
So it is as if the files were deleted. AFAIK deletion happens more often  
when the file is not accessed for given time specified through the  
inactive  
parameter of the proxy\_cache\_path/fastcgi\_cache\_path directives.

----appa

On Mon, Dec 30, 2013 at 5:27 AM, Indo P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Hi
