Extra cache dirtying

Some pages weren't getting dirtied appropriately on change.
This commit is contained in:
Robin Malley 2021-08-27 01:08:02 +00:00
parent f88ec0e22a
commit 4913e7765e
4 changed files with 11 additions and 1 deletions

View File

@ -92,6 +92,7 @@ local function edit_post(req)
cache.dirty(string.format("%s/%s",config.domain,id_enc)) -- This place to read this post
cache.dirty(string.format("%s",config.domain)) -- The site index (ex, if the author changed the paste from their's to "Anonymous", the cache should reflect that).
cache.dirty(string.format("%s.%s",author,config.domain)) -- The author's index, same reasoning as above.
cache.dirty(string.format("%s-logout",config.domain))
http_response_header(req,"Location",loc)
http_response(req,303,"")
return

View File

@ -112,7 +112,8 @@ local function index_get(req)
end)
elseif host == config.domain and author then
--Display home page with "log out" button
text = cache.render(config.domain .. "-logout", function()
local cachepath = string.format("%s-logout",config.domain)
text = cache.render(cachepath, function()
return get_site_home(req,true)
end)
elseif host ~= config.domain and author ~= subdomain then

View File

@ -148,6 +148,7 @@ local function author_paste(req,ps)
cache.dirty(string.format("%s.%s",author,config.domain))
cache.dirty(string.format("%s/%s",config.domain,url))
cache.dirty(string.format("%s",config.domain))
cache.dirty(string.format("%s-logout",config.domain))
end
http_response_header(req,"Location",loc)
http_response(req,303,"")

View File

@ -8,6 +8,7 @@ local util = require("util")
local cache = require("cache")
local pages = require("pages")
local config = require("config")
local zlib = require("zlib")
local stmnt_read, stmnt_update_views, stmnt_comments
@ -175,6 +176,12 @@ local function read_get(req)
text = pages.read(ps)
end
end
--If this isn't unlisted, dirty everywhere the hit counter is shown
cache.dirty(string.format("%s",config.domain))
cache.dirty(string.format("%s/%s",config.domain,ps.idp)) -- This place to read this post
cache.dirty(string.format("%s/%s",config.domain,ps.idp)) -- The author's index page
assert(text)
http_response(req,200,text)
return