cloudflare / cloudflare/lua-upstream-cache-nginx-module

the module is unvalid when upstream_cache_status is HIT

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
124
Forks
40
PR merge metrics
No merged PRs in 30d

Description

hi:
I use the module to set meta info when upstream_cache_status is HIT, but I found this is unvalid.

code:
header_filter_by_lua '
local http_cache = require("http_cache")
local cache_status = (ngx.var.upstream_cache_status or "")

if cache_status == "HIT" and ngx.ctx.flag == "true" then
local cache_data = http_cache.get_metadata()
local new_expire = ngx.time() - 1

if cache_data and cache_data["valid_sec"] then
http_cache.set_metadata({ valid_sec = new_expire,
fcn = { valid_sec = new_expire,
expire = new_expire } })
end
end
';

Can I use it like this? thx!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.