# \*\_cache\_revalidate directives

**URL:** <https://www.ruby-forum.com/t/cache-revalidate-directives/242630>\
**Category:** NGINX\
**Created:** [July 9, 2015, 3:44am UTC](https://www.ruby-forum.com/t/cache-revalidate-directives/242630 "2015-07-09T03:44:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [July 9, 2015, 3:44am UTC](https://www.ruby-forum.com/t/cache-revalidate-directives/242630/1 "2015-07-09T03:44:15Z")

</div>

Hello,

From the documentation, I don’t understand how the  
fastcgi\_cache\_revalidate  
(or scgi\_cache\_revalidate or proxy\_cache\_revalidate or  
uwsgi\_cache\_revalidate) works.  
Please, can someone explain what nginx does when cache is enabled and  
the  
revalidate directive is set to “on”?

Best Regards

Posted at Nginx Forum:

> **[\*\_cache\_revalidate directives](https://forum.nginx.org/read.php?2,260148,260148#msg-260148)**
>
> Hello, From the documentation, I don't understand how the fastcgi\_cache\_revalidate (or scgi\_cache\_revalidate or proxy\_cache\_revalidate or uwsgi\_cache\_revalidate) works. Please, can someone explain what nginx does when cache is enabled and the...

---

<div class="post-metadata">

**Author:** ![Alt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@Alt](https://www.ruby-forum.com/u/Alt)\
**Post date:** [July 9, 2015, 9:31am UTC](https://www.ruby-forum.com/t/cache-revalidate-directives/242630/2 "2015-07-09T09:31:20Z")

</div>

Hello,

> On 09 Jul 2015, at 04:43, Alt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> Hello,
> 
> From the documentation, I don’t understand how the fastcgi\_cache\_revalidate  
> (or scgi\_cache\_revalidate or proxy\_cache\_revalidate or  
> uwsgi\_cache\_revalidate) works.  
> Please, can someone explain what nginx does when cache is enabled and the  
> revalidate directive is set to “on”?

Normally, when a cache entry is expired in nginx cache, nginx fetches a  
replacement from upstream.  
If cache revalidation is enabled, nginx asks the upstream if the current  
(expired) entry is still  
valid using “If-Modified-Since” and “If-None-Match” HTTP headers. The  
upstream can reply with  
“304 Not Modified” to confirm the validity. In this case the entry  
remains in cache until it  
expires again.

–  
Roman A.

---

<div class="post-metadata">

**Author:** ![Alt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@Alt](https://www.ruby-forum.com/u/Alt)\
**Post date:** [July 9, 2015, 9:59am UTC](https://www.ruby-forum.com/t/cache-revalidate-directives/242630/3 "2015-07-09T09:59:23Z")

</div>

Hello Roman,

Thanks for the explanation.  
At which moment this revalidation is executed? When there’s a new client  
request or is it done automatically when a cache entry is about to  
expire?  
The nginx’s cache manager is deleting expiring cache file, so I’m not  
sure  
to understand how it all works.

Best Regards

Posted at Nginx Forum:

> **[Re: \*\_cache\_revalidate directives](https://forum.nginx.org/read.php?2,260148,260151#msg-260151)**
>
> Hello, From the documentation, I don't understand how the fastcgi\_cache\_revalidate (or scgi\_cache\_revalidate or proxy\_cache\_revalidate or uwsgi\_cache\_revalidate) works. Please, can someone explain what nginx does when cache is enabled and the...

---

<div class="post-metadata">

**Author:** ![Alt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@Alt](https://www.ruby-forum.com/u/Alt)\
**Post date:** [July 9, 2015, 10:32am UTC](https://www.ruby-forum.com/t/cache-revalidate-directives/242630/4 "2015-07-09T10:32:41Z")

</div>

Hello,

> On 09 Jul 2015, at 10:59, Alt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> Hello Roman,
> 
> Thanks for the explanation.  
> At which moment this revalidation is executed? When there’s a new client  
> request or is it done automatically when a cache entry is about to expire?

When there’s a client request.  
Nginx does not do any background cache updates/revalidations/etc.

> The nginx’s cache manager is deleting expiring cache file, so I’m not sure  
> to understand how it all works.

Nginx cache manager has nothing to do with cache entry expiration.  
In fact, it does 2 things:

- deletes files which were not accessed for the “inactive” time
- deletes old files to keep cache within “max\_size”

> **[Module ngx\_http\_proxy\_module](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_path)**
>
> The ngx\_http\_proxy\_module module allows passing requests to another server.

–  
Roman A.

---

<div class="post-metadata">

**Author:** ![Alt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@Alt](https://www.ruby-forum.com/u/Alt)\
**Post date:** [July 10, 2015, 1:18pm UTC](https://www.ruby-forum.com/t/cache-revalidate-directives/242630/5 "2015-07-10T13:18:02Z")

</div>

Hello,

Thanks again Roman for the explanation and link!

Best Regards

Posted at Nginx Forum:

> **[Re: \*\_cache\_revalidate directives](https://forum.nginx.org/read.php?2,260148,260179#msg-260179)**
>
> Hello, From the documentation, I don't understand how the fastcgi\_cache\_revalidate (or scgi\_cache\_revalidate or proxy\_cache\_revalidate or uwsgi\_cache\_revalidate) works. Please, can someone explain what nginx does when cache is enabled and the...
