yaoweibin / ngx_http_substitutions_filter_module

a filter module which can do both regular expression and fixed string substitutions for nginx
607 stars 213 forks source link

how to keep original Last-Modified date #23

Open cenggel opened 7 years ago

cenggel commented 7 years ago

after apply subs_filter to js file the "Last-Modified" header removed and nginx cache config will not work always return 200 state and js file content.

who to cache subs_filtered static resource?

oxjtt5i5wm commented 6 years ago

This issue is simple. In ngx_http_subs_filter_module.c, line 270, ngx_http_clear_last_modified is called to unconditionally remove Last-Modified header.

if (r == r->main) {
    ngx_http_clear_content_length(r);
    ngx_http_clear_last_modified(r);
}

It is not possible to customize this behavior. While it's trivial to patch it, and pull requests are welcomed for any open source project, it looks like the project is no longer maintained. ngx_http_sub_filter_module in the mainline is NOT the same as this module, it is separately maintained, in line 271, both Last-Modified and ETag is removed.

if (!slcf->last_modified) {
    ngx_http_clear_last_modified(r);
    ngx_http_clear_etag(r);

} else {
    ngx_http_weak_etag(r);
}

You should report the problem to the upstream, fill a feature request for keeping Last-Modified and ETag, instead of reporting bugs here.

You can also use https://github.com/openresty/replace-filter-nginx-module instead, it is well-maintained by a reputable developer, @agentzh.

AnYiEE commented 1 year ago

You can use this fork: AnYiEE/ngx_http_substitutions_filter_module.