Skip to content

Instantly share code, notes, and snippets.

@Robbilie
Created November 22, 2021 21:29
Show Gist options
  • Save Robbilie/0365dac0cf5e17f27946d5ff4eb08c59 to your computer and use it in GitHub Desktop.
Save Robbilie/0365dac0cf5e17f27946d5ff4eb08c59 to your computer and use it in GitHub Desktop.
proxy_cache_purge for nginx free
access_by_lua_block {
if ngx.var.request_method == "PURGE" then
local hash = ngx.md5(ngx.var.request_uri)
local p1 = string.sub(hash, -1)
local p2 = string.sub(hash, -3, -2)
os.remove("/tmp/nginx-cache-default" .. p1 .. "/" .. p2 .. "/" .. hash)
ngx.exit(ngx.HTTP_NO_CONTENT)
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment