Created
November 22, 2021 21:29
-
-
Save Robbilie/0365dac0cf5e17f27946d5ff4eb08c59 to your computer and use it in GitHub Desktop.
proxy_cache_purge for nginx free
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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