nginx_cache_multipurge icon indicating copy to clipboard operation
nginx_cache_multipurge copied to clipboard

Purge /

Open peixotorms opened this issue 2 years ago • 1 comments

Hi

According to the docs:

Request GET /cache/purge/path/to/images/myimage.png to purge that image.
Request GET /cache/purge/images/my* to purge all images that start with my in that path.
Request GET /cache/purge/* to purge all the cache.

But how to purge / only?

If I try GET /cache/purge/ I get

*6 lua entry thread aborted: runtime error: /etc/nginx/lua/cache_multipurge.lua:73: attempt to call field 'sumhexa' (a nil value)
stack traceback:
coroutine 0:
        /etc/nginx/lua/cache_multipurge.lua: in function 'purge_one'
        /etc/nginx/lua/cache_multipurge.lua:91: in main chunk, client: 127.0.0.1
(...)

peixotorms avatar May 04 '22 14:05 peixotorms

It looks like my version of lua-md5 did not support the sumhexa function, so I solved it by removing the dependency altogether. Just replace the function purge_one() to let the OS do the md5 directly, rather than rely on the lua module. Pull request sent. https://github.com/diego-treitos/nginx_cache_multipurge/pull/11

function purge_one()
  os.execute( "VAR=$(echo -n "..cmp_cache_key.." | md5sum | awk '{print $1}'); find '"..cmp_cache_path.."' -name ${VAR} -type f -exec rm {} + " )
end

peixotorms avatar May 04 '22 18:05 peixotorms