-
Notifications
You must be signed in to change notification settings - Fork 104
Added expiration time variable #26
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
Conversation
@asierguti Thank you for the patch! Will you mind adding some corresponding test cases to the existing test suite to demonstrate how it actually works? Thanks! |
Well, I have a couple of scripts in python. The idea is to create a simple HTTP server which sends an HTTP answer with the current timestamp in the body. The second script will just try to retrieve a particular URL, then wait a number of seconds, and try to grab the same URL once again. It will check if it was due to recache or not, and it will check the timestamp in the body. I will upload both scripts shortly. |
@asierguti Okay, I've had a closer look and got your idea. Basically you want to validate the response from the Before your patch can be merged, please adjust the coding style to be consistent with the existing code base and preferably with test cases in your patch for the existing test scaffold. (BTW, I'm not interested in your Python scripts and I don't want to include any Python code in the existing test suite that is driven completely by Perl. Please look at the existing test cases for examples). |
@asierguti Also, I think it's a good idea to introduce a And for the automatic "Expires" header insertion part, I must say I don't like it. It is just totally wrong to always blindly override the original "Expires" response header. Though it is what you want for your particular use case but it will break others' setup. A better approach for Expires response header insertion for your use case is to use |
Thanks a lot for your feedback. First of all, I will try to translate all our tests to perl. It will take Regarding your suggestions, I didn't quite get what you said about Now, regarding your suggestion about LUA. To be honest, I thought about it Cheers. On 19 March 2014 23:16, Yichun Zhang notifications@github.com wrote:
|
Hi, I don't know if you saw my previous comment. In case you missed it, or I did something wrong posting it, here it goes once again. Thanks a lot for your feedback. First of all, I will try to translate all our tests to perl. I'm in the process of doing so. I just have one small question. I would like to get in a variable the current time when testing (request part in the test), and compare it to the response. How could I do it? I can get the current time in a variable, but I don't seem to find how I can extract the "Expires" header, and compare it to the previous data. Regarding your suggestions, I didn't quite get what you said about rcache_fetch_validate_expires on|off.How is this feature supposed to work? Having our frontend servers check the expiration dates of all the data in our backend storage servers will increase the traffic network. Network is more important than CPU cycles, at least for us. Now, regarding your suggestion about LUA. To be honest, I thought about it before. The thing is that we want to have flexibility to adjust the expiration time according to the response code we get from our real backend server (not the cache storage backend). For example, if we get 200, we would like to cache the data for a week, but if we get 301, we would like to cache it only for a day. That's why $srcache_expires was not suitable for us. If you have any suggestion, I will be glad to consider it. Looking forward to hearing from you. Cheers. |
@asierguti Sorry, I'm currently busy with the company work. I'll get back to you as soon as I can manage :) Thanks! |
src/ngx_http_srcache_fetch.c
Outdated
@@ -538,15 +548,20 @@ ngx_http_srcache_test_precondition(ngx_http_request_t *r) | |||
static void | |||
ngx_http_srcache_post_read_body(ngx_http_request_t *r) | |||
{ | |||
if (r == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: we use 4 space indentation.
We are working on using srcache for caching data from our backend servers into our own database, sos that the frontend server can just retrieve the data from the cache.
In order to make sure that the data gets purged from time to time, and that we don't send "old" data from the cache, we wanted to add an "Expires" variable in the data header that is being cached, so that we know when we have to recache the data, and when we have to delete old data.
This patch just adds a new configuration variable in the form of "srcache_cache_valid <HTTP_STATUS> ", and a callback to analyze the expiration time from the fetched data and make sure we recache the data if the one in the cache is old enough.