# Proxy\_cache not honoring pragma/cache-control settings

**URL:** <https://www.ruby-forum.com/t/proxy-cache-not-honoring-pragma-cache-control-settings/207879>\
**Category:** NGINX\
**Created:** [June 5, 2011, 7:55am UTC](https://www.ruby-forum.com/t/proxy-cache-not-honoring-pragma-cache-control-settings/207879 "2011-06-05T07:55:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [June 5, 2011, 7:55am UTC](https://www.ruby-forum.com/t/proxy-cache-not-honoring-pragma-cache-control-settings/207879/1 "2011-06-05T07:55:48Z")

</div>

Hi, from the documentation I understand that proxy\_cache will NOT be  
activated for pages that have pragma to “no-cache” or Cache-control to  
“no-cache”, or even Expires to an old date.

I have the following in my Location settings:

proxy\_cache\_bypass $http\_pragma $http\_authorization;  
proxy\_no\_cache $http\_pragma $http\_authorization;

And this at the top of my PHP pages that I do not want cached, as they  
change often and for the logged in user:

header(“Cache-control: private, no-cache, must-revalidate”);  
header(“Expires: Mon, 24 Sep 1997 05:00:00 GMT”); # Past date  
header(“Pragma: no-cache”);

However, these pages are still being cached.

Any insight on what I am missing?

Thanks!

Posted at Nginx Forum:

> **[proxy\_cache not honoring pragma/cache-control settings](https://forum.nginx.org/read.php?2,204026,204026#msg-204026)**
>
> Hi, from the documentation I understand that proxy\_cache will NOT be activated for pages that have pragma to "no-cache" or Cache-control to "no-cache", or even Expires to an old date. I have the following in my Location settings:...

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 5, 2011, 8:14am UTC](https://www.ruby-forum.com/t/proxy-cache-not-honoring-pragma-cache-control-settings/207879/2 "2011-06-05T08:14:18Z")

</div>

On Sun, Jun 05, 2011 at 01:55:03AM -0400, pk899 wrote:

> And this at the top of my PHP pages that I do not want cached, as they  
> change often and for the logged in user:
> 
> header(“Cache-control: private, no-cache, must-revalidate”);  
> header(“Expires: Mon, 24 Sep 1997 05:00:00 GMT”); # Past date  
> header(“Pragma: no-cache”);

“Pragma: no-cache” sent from server side means nothing.  
$http\_pragma means client “Pragma” header.

> However, these pages are still being cached.
> 
> Any insight on what I am missing?

nginx should not cache response with such Cache-Control and Expires.  
Do you have proxy\_ignore\_header directive ?

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 5, 2011, 8:21am UTC](https://www.ruby-forum.com/t/proxy-cache-not-honoring-pragma-cache-control-settings/207879/3 "2011-06-05T08:21:05Z")

</div>

Yes I have this:

proxy\_ignore\_headers Cache-Control Expires;

Is this why this is happening?

Posted at Nginx Forum:

> **[Re: proxy\_cache not honoring pragma/cache-control settings](https://forum.nginx.org/read.php?2,204026,204030#msg-204030)**
>
> Hi, from the documentation I understand that proxy\_cache will NOT be activated for pages that have pragma to "no-cache" or Cache-control to "no-cache", or even Expires to an old date. I have the following in my Location settings:...

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 5, 2011, 8:24am UTC](https://www.ruby-forum.com/t/proxy-cache-not-honoring-pragma-cache-control-settings/207879/4 "2011-06-05T08:24:10Z")

</div>

Wow, sorry, I feel stupid. I commented that line and now it works.

Thanks!!

Posted at Nginx Forum:

> **[Re: proxy\_cache not honoring pragma/cache-control settings](https://forum.nginx.org/read.php?2,204026,204031#msg-204031)**
>
> Hi, from the documentation I understand that proxy\_cache will NOT be activated for pages that have pragma to "no-cache" or Cache-control to "no-cache", or even Expires to an old date. I have the following in my Location settings:...

---

<div class="post-metadata">

**Author:** ![pk899](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@pk899](https://www.ruby-forum.com/u/pk899)\
**Post date:** [June 5, 2011, 8:24am UTC](https://www.ruby-forum.com/t/proxy-cache-not-honoring-pragma-cache-control-settings/207879/5 "2011-06-05T08:24:10Z")

</div>

On Sun, Jun 05, 2011 at 02:20:24AM -0400, pk899 wrote:

> Yes I have this:
> 
> proxy\_ignore\_headers Cache-Control Expires;
> 
> Is this why this is happening?

Yes, nginx ignores these headers in backend response.  
And, as I already said Pragma means nothing.

–  
Igor S.
