-
Notifications
You must be signed in to change notification settings - Fork 105
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
Why still get into srcache_store handler even if $srcache_expire=0? #45
Comments
@wonderbeyond I think you should use the |
I known |
@wonderbeyond You can always use access_by_lua* or rewrite_by_lua* to evaluate the value of your custom nginx variable for |
@wonderbeyond Given that |
@agentzh thank you, I've understood that I think it's perfect if my cache layer can interact with upstream, so I've made use of You recommend me:
However, since I need to combine factors from upstream response to evaluate the value, access_by_lua* and rewrite_by_lua* won't work. So what's the possible place? |
@wonderbeyond It's possible with |
@agentzh Thanks, I will give a try. I will set PS: I'm using original Nginx plused plugins coming from OpenResty. |
So late I am back here again. Below is my new configuration sample: server {
set $canonical_host www.example.com;
# ...
set_escape_uri $pagecache_key $canonical_host$uri$is_args$args;
set $pagecache_exptime '';
header_filter_by_lua_block {
# MY DOUBT: this block runs in `output-header-filter` phase.
# Can I ensure this block always run after `$srcache_expire` is evaluated???
if not ngx.var.pagecache_exptime or ngx.var.pagecache_exptime == '' then
ngx.var.pagecache_exptime = ngx.var.srcache_expire
end
}
srcache_fetch GET /pagecache key=$pagecache_key;
srcache_store PUT /pagecache key=$pagecache_key&exptime=$pagecache_exptime;
location /foo {
# I've set $pagecache_exptime, so I **dont respect upstream's Cache-Control**
set $pagecache_exptime 1y;
}
location /bar {
# I dont set `$pagecache_exptime` and **respect upstream's Cache-Control**
}
# ...
} I leveraged the auto-evaluated I compute my exptime in PS: I'm not using 100% OpenResty, but a self-built nginx using many components form OpenResty. |
I just put my srcache settings directly under
server
block:You see, I use
srcache_default_expire
, So the$srcache_expire
will default to0
,I expect my upstream setting their appropriate exptime by
max-age
.However, my
srcache_store
get involved even if$srcache_expire==0
,and then cause an extra useless redis request.
The text was updated successfully, but these errors were encountered: