-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace_filter removes some Caching headers. #8
Comments
@bhargavtrivedi The ngx_replace_filter module clears the "Last-Modified" response header in its header filter because its body filter may change the response (body), so the original "Last-Modifiled" response header may become logically invalid. And it's also wrong for the ngx_replace_filter to insert a new "Last-Modified" response header by using the current timestamp because ngx_replace_filter's body filter may not change the response body but it cannot be known in advance in the header filter because the body filter has not run yet. Do you want to retain the original Last-Modified response header with force or overwrite it with the current timestamp? |
Hi, Thanks for your explanation. I would like to know both options,
If the original file is not modified, I just want to send 304 response code to the client. Thanks |
Hello agentzh, Is it possible to retain Last-Modified response header? If it is possible, can you suggest me the solutions for both of the options I mentioned in previous comment? Thanks, |
@bhargavtrivedi For the 1st option, I just implemented the replace_filter_last_modified directive in this module. See https://github.com/agentzh/replace-filter-nginx-module/#replace_filter_last_modified for the documentation. For the 2nd option, you can use ngx_lua module's header_filter_by_lua '
ngx.header["Last-Modified"] = ngx.http_time(ngx.time())
'; See ngx_lua's documentation for more details: https://github.com/chaoslawful/lua-nginx-module#readme You should ensure that ngx_lua's header filter runs after ngx_replace_filter's. To do that, you need to add these two modules in the reversed order while building Nginx, that is, ./configure --add-module=/path/to/lua-nginx-module \
--add-module=/path/to/replace-filter-nginx-module |
Hi, Thanks for your quick updates on this. For first option, I will have to build rpm with new version of this module so I will build and check it. I am using lua to gunzip the backend response so I can not run it after replace_filter. I am not sure if there is any other better option to gunzip backend response. One more thing I would like to know, which of the below two options is better to use?
Which one of the above two is faster and less CPU expensive? There is also HttpSubsModule in Nginx, is there any limitation of that compare to replace_filter module ? And which one is faster if you may have some benchmarking after development of replace filter? I really appreciate your help on this new feature to retain original "Last-Modified" header. Thanks, |
Hello agentzh, I build new rpm and tested new version of replace_filter. Now it can preserve "Last-Modified" headers. Thanks for your help on this. If you get bit, would you check my previous post? I have few queries and I would like to have your suggestions for those. Thanks, |
Hello! On Tue, Nov 19, 2013 at 11:09 PM, bhargavtrivedi wrote:
It'll be much hard to do text replacement in body_filter_by_lua
The ngx_subs module uses a backtracking regex engine that can only But you should also keep in mind that the sregex engine used by Regards, |
Hello agentzh, Thanks for the explanation. If I use multiple replace_filter regex rules to modify response body, do you think it will increase response time of the request(delay response)? Regards, |
Hello! On Sat, Nov 30, 2013 at 12:24 AM, bhargavtrivedi wrote:
When you add more regex rules, you add more complexity to your pattern -agentzh |
Hello,
I am using Nginx as web server and I tried to implement replace_filter module for removing some part of response. This implementation works fine for me but it has caused one issue. It also removes some important response headers.
I tried to look into the code of replace filter and found that it removes "last modified" headers because of which the response can not be cached.
Would you explain why is it important to remove "last modified" response headers? And would you suggest some solution to enable it again after processing replace_filter code?
Thanks,
Bhargav
The text was updated successfully, but these errors were encountered: