# Serving from cache even when the origin server goes down

**URL:** <https://www.ruby-forum.com/t/serving-from-cache-even-when-the-origin-server-goes-down/242520>\
**Category:** NGINX\
**Created:** [June 30, 2015, 3:27am UTC](https://www.ruby-forum.com/t/serving-from-cache-even-when-the-origin-server-goes-down/242520 "2015-06-30T03:27:54Z")\
**Posts on this page:** 3\
**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:** [June 30, 2015, 3:27am UTC](https://www.ruby-forum.com/t/serving-from-cache-even-when-the-origin-server-goes-down/242520/1 "2015-06-30T03:27:54Z")

</div>

Is it possible to configure Nginx to serve from cache even when the  
origin  
server is not accessible?

I am trying to figure out if I can use a replicated Nginx instance that  
has  
cache files rsynced (lsyncd  
[http://t.sidekickopen03.com/e1t/c/5/f18dQhb0S7lC8dDMPbW2n0x6l2B9nMJW7t5XYg1qwrMlW63Bdqv8rBw8YW4XXPpC56dBXDf1zVF0j02?t=https%3A%2F%2Fcode.google.com%2Fp%2Flsyncd%2F&si=6435350837723136&pi=2518a249-a8f4-4dd6-9e96-783723ac8e1a](http://t.sidekickopen03.com/e1t/c/5/f18dQhb0S7lC8dDMPbW2n0x6l2B9nMJW7t5XYg1qwrMlW63Bdqv8rBw8YW4XXPpC56dBXDf1zVF0j02?t=https%3A%2F%2Fcode.google.com%2Fp%2Flsyncd%2F&si=6435350837723136&pi=2518a249-a8f4-4dd6-9e96-783723ac8e1a))  
from the primary instance and serve from the replicated instance (DNS  
switch) if the primary goes down.

- Cherian

---

<div class="post-metadata">

**Author:** ![Cherian\_Thomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Cherian\_Thomas](https://www.ruby-forum.com/u/Cherian_Thomas)\
**Post date:** [June 30, 2015, 7:01am UTC](https://www.ruby-forum.com/t/serving-from-cache-even-when-the-origin-server-goes-down/242520/2 "2015-06-30T07:01:42Z")

</div>

[http://nginx.org/en/docs/http/ngx\_http\_proxy\_module.html#proxy\_cache\_use\_stale](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_use_stale)

You can use multiple values e.g. the below is probably a good start:

proxy\_cache\_use\_stale error timeout invalid\_header updating;

---

<div class="post-metadata">

**Author:** ![Cherian\_Thomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Cherian\_Thomas](https://www.ruby-forum.com/u/Cherian_Thomas)\
**Post date:** [June 30, 2015, 5:36pm UTC](https://www.ruby-forum.com/t/serving-from-cache-even-when-the-origin-server-goes-down/242520/3 "2015-06-30T17:36:45Z")

</div>

Thanks a lot. This is perfect.

- Cherian
