Welcome! Log In Create A New Profile

Advanced

Re: Disable NGINX caching 304 Responses from Origin Server

July 25, 2017 03:26AM
That's an interesting solution. Would nginx still cache our other items
as normal using this config? We specify cache settings via
Cache-Control and Expires headers sent from the origin server. Also, we
are using X-Accel-Expires for some pages which are sent from the origin
server too. This wouldn't affect any of our caching? It would simply
not cache any resources with 304 sent from the origin?

Another thought... would proxy_cache_valid override the Expires /
Cache-Control headers sent along with the 304 response from the origin
server? Because with these 304 responses, the origin server sets a 3
month expires.

Thank you for your help, it's much appreciated.



On 25/07/2017 02:35, Zhang Chao wrote:
>
> Hi!
>
> Have you used the proxy_cache_valid
> <http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid>?
>
> Maybe you can add this directive to disable the 304 cache explicitly.
>
> |proxy_cache_valid 304 0;|
>
> On 24 July 2017 at 23:20:35, Ryan Barclay (ryan@rbftpnetworks.com
> <mailto:ryan@rbftpnetworks.com>) wrote:
>
>> We have a pretty simple setup with NGINX sitting on the front and a
>> backend server (on a separate physical server) that provides the
>> content.
>>
>> Nginx then caches content based on the EXPIRES and Cache-Control headers
>> set by the origin server.
>>
>> We noticed that NGINX was not issuing 304 headers to images that were
>> not in the local NGINX cache when the If-Modified-Since header was sent
>> by the client. Instead, it would issue a 200 with the full data file.
>>
>> To fix this, we applied:
>> proxy_set_header If-Modified-Since $http_if_modified_since
>>
>> So then the If-Modified-Since header was passed to the backend and of
>> course, it returned correctly with the 304 header - great.
>>
>> But what we noticed was that NGINX would cache this 304 response and
>> deliver future responses as 304 to clients even without the
>> If-Modified-Since header.
>>
>> How can we disable caching of 304 responses and fix this issue?
>>
>> Thank you for your help, suggestions, and tips in advance.
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org <mailto:nginx@nginx.org>
>> http://mailman.nginx.org/mailman/listinfo/nginx
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Disable NGINX caching 304 Responses from Origin Server

ryanrbftp July 24, 2017 11:22AM

Re: Disable NGINX caching 304 Responses from Origin Server

tokers July 24, 2017 09:36PM

Re: Disable NGINX caching 304 Responses from Origin Server

ryanrbftp July 25, 2017 03:26AM

Re: Disable NGINX caching 304 Responses from Origin Server

ryanrbftp July 26, 2017 03:30AM

Re: Disable NGINX caching 304 Responses from Origin Server

pbooth July 26, 2017 04:12AM

Re: Disable NGINX caching 304 Responses from Origin Server

ryanrbftp July 26, 2017 04:58AM

Re: Disable NGINX caching 304 Responses from Origin Server

ryanrbftp July 26, 2017 05:12AM

Re: Disable NGINX caching 304 Responses from Origin Server

pbooth July 26, 2017 05:44AM

Re: Disable NGINX caching 304 Responses from Origin Server

ryanrbftp July 26, 2017 06:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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