Skip to content

Commit

Permalink
Update cache control
Browse files Browse the repository at this point in the history
  • Loading branch information
javalikescript committed May 8, 2022
1 parent 6bcda49 commit 86dc4aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extensions/web-base/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"default": "assets"
},
"cache": {
"title": "Cache control duration, 0 to disable",
"title": "Cache control duration for assets, 0 to disable",
"type": "integer",
"default": 86400
},
Expand Down
6 changes: 3 additions & 3 deletions extensions/web-base/web-base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function extension:registerAddonExtension(ext, script)
script = ext:getId()..'.js'
end
self:registerAddon(ext:getId(), {
handler = AddonFileHttpHandler:new(ext:getDir()):setCacheControl(configuration.cache),
handler = AddonFileHttpHandler:new(ext:getDir()),
script = script or 'main.js' -- TODO change to init
})
end
Expand All @@ -128,7 +128,7 @@ extension:subscribeEvent('startup', function()
local assetsHandler
if assets:isDirectory() then
logger:info('Using assets directory "'..assets:getPath()..'"')
assetsHandler = FileHttpHandler:new(assets)
assetsHandler = FileHttpHandler:new(assets):setCacheControl(configuration.cache)
elseif assets:isFile() and string.find(assets:getPathName(), '%.zip$') then
logger:info('Using assets file "'..assets:getPath()..'"')
assetsHandler = ZipFileHttpHandler:new(assets)
Expand All @@ -139,7 +139,7 @@ extension:subscribeEvent('startup', function()
local wwwDir = File:new(extension:getDir(), 'www')

cleanup(server)
addContext(server, '/(.*)', FileHttpHandler:new(wwwDir, 'r', 'app.html'):setCacheControl(configuration.cache))
addContext(server, '/(.*)', FileHttpHandler:new(wwwDir, 'r', 'app.html'))
addContext(server, '/static/(.*)', assetsHandler)
addContext(server, '/addon/([^/]*)/?(.*)', HttpHandler:new(function(self, exchange)
local name, path = exchange:getRequestArguments()
Expand Down

0 comments on commit 86dc4aa

Please sign in to comment.