[nginx] Entity tags: explicit flag to skip not modified filter.

Maxim Dounin mdounin at mdounin.ru
Wed Jul 16 15:54:03 UTC 2014


On Mon, Jul 14, 2014 at 03:58:10PM -0700, Yichun Zhang (agentzh) wrote:

> Hello!
> On Wed, Jun 25, 2014 at 3:40 PM, Maxim Dounin wrote:
> >
> > +    r->disable_not_modified = !u->cacheable;
> > +
> Hmm, this line of change is giving me problems to fix the new
> regression in my ngx_memc module's "memc_flags_to_last_modified"
> feature (https://github.com/openresty/memc-nginx-module#memc_flags_to_last_modified
> ) caused by nginx 1.7.3.
> It seems that there is no hooks for 3rd-party upstream C modules to
> override this r->disable_not_modified field? The nearest hook,
> u->process_header, is called *before* the
> ngx_http_upstream_process_headers function setting this flag. And
> setting u->cacheable leads to undesired side effects in
> ngx_http_upstream_send_response(), which is also just too hacky.
> Any hints on this?

As the r->disable_not_modified is a flag that affects response 
returned, it's something to be set during the copy headers 
process.  Protocol modules are not expected to be able to (and 
even try to) influence this except by providing appropriate 
upstream response headers.

The same applies to r->headers_out.last_modified_time 
modifications in your module - what previously worked in your 
module was a hack, and there is no surprise it no longer works 
after changes.

I see two possible ways to make it work again:

- Implement appropriate flag in upstream (or upstram 
  configuration) to make it possible to activate not modified 
  filter for responses which doesn't use cache.

- Emulate 304 responses by the module itself.

The latter is obviously easier from nginx core point of view.  :) 
Also, it should be compatible with all nginx versions.

Maxim Dounin

More information about the nginx-devel mailing list