Merge pull request '[#9064] Fix CSS and Image caching issue' (#9082) from yawhn/elreqkey:calckey_issue_9064 into develop
Reviewed-on: https://codeberg.org/thatonecalculator/calckey/pulls/9082
This commit is contained in:
commit
80161e8280
|
@ -42,6 +42,9 @@ const app = new Koa();
|
||||||
//#region Bull Dashboard
|
//#region Bull Dashboard
|
||||||
const bullBoardPath = '/queue';
|
const bullBoardPath = '/queue';
|
||||||
|
|
||||||
|
// used as a url param to prevent caching css and images
|
||||||
|
const nowDateMs = Date.now();
|
||||||
|
|
||||||
// Authenticate
|
// Authenticate
|
||||||
app.use(async (ctx, next) => {
|
app.use(async (ctx, next) => {
|
||||||
if (ctx.path === bullBoardPath || ctx.path.startsWith(bullBoardPath + '/')) {
|
if (ctx.path === bullBoardPath || ctx.path.startsWith(bullBoardPath + '/')) {
|
||||||
|
@ -295,6 +298,7 @@ router.get(['/@:user', '/@:user/:sub'], async (ctx, next) => {
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
privateMode: meta.privateMode,
|
privateMode: meta.privateMode,
|
||||||
|
nowDateMs: nowDateMs,
|
||||||
});
|
});
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
} else {
|
} else {
|
||||||
|
@ -340,6 +344,7 @@ router.get('/notes/:note', async (ctx, next) => {
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
privateMode: meta.privateMode,
|
privateMode: meta.privateMode,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
nowDateMs: nowDateMs,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
@ -377,6 +382,7 @@ router.get('/@:user/pages/:page', async (ctx, next) => {
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
privateMode: meta.privateMode,
|
privateMode: meta.privateMode,
|
||||||
|
nowDateMs: nowDateMs,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (['public'].includes(page.visibility)) {
|
if (['public'].includes(page.visibility)) {
|
||||||
|
@ -410,6 +416,7 @@ router.get('/clips/:clip', async (ctx, next) => {
|
||||||
privateMode: meta.privateMode,
|
privateMode: meta.privateMode,
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
nowDateMs: nowDateMs,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
@ -436,6 +443,7 @@ router.get('/gallery/:post', async (ctx, next) => {
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
privateMode: meta.privateMode,
|
privateMode: meta.privateMode,
|
||||||
|
nowDateMs: nowDateMs,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
@ -461,6 +469,7 @@ router.get('/channels/:channel', async (ctx, next) => {
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
privateMode: meta.privateMode,
|
privateMode: meta.privateMode,
|
||||||
|
nowDateMs: nowDateMs,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
@ -536,6 +545,7 @@ router.get('(.*)', async ctx => {
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
randomMOTD: motd[Math.floor(Math.random() * motd.length)],
|
randomMOTD: motd[Math.floor(Math.random() * motd.length)],
|
||||||
privateMode: meta.privateMode,
|
privateMode: meta.privateMode,
|
||||||
|
nowDateMs: nowDateMs,
|
||||||
});
|
});
|
||||||
ctx.set('Cache-Control', 'public, max-age=3');
|
ctx.set('Cache-Control', 'public, max-age=3');
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,15 +29,14 @@ html
|
||||||
meta(property='twitter:card' content='summary')
|
meta(property='twitter:card' content='summary')
|
||||||
meta(property='og:site_name' content= instanceName || 'Calckey')
|
meta(property='og:site_name' content= instanceName || 'Calckey')
|
||||||
meta(name='viewport' content='width=device-width, initial-scale=1')
|
meta(name='viewport' content='width=device-width, initial-scale=1')
|
||||||
meta(name='darkreader-lock')
|
link(rel='icon' href= icon || `/favicon.ico?${ nowDateMs }`)
|
||||||
link(rel='icon' href= icon || '/favicon.ico')
|
link(rel='apple-touch-icon' href= icon || `/apple-touch-icon.png?${ nowDateMs }`)
|
||||||
link(rel='apple-touch-icon' href= icon || '/apple-touch-icon.png')
|
|
||||||
link(rel='manifest' href='/manifest.json')
|
link(rel='manifest' href='/manifest.json')
|
||||||
link(rel='prefetch' href='/static-assets/badges/info.png')
|
link(rel='prefetch' href=`/static-assets/badges/info.png?${ nowDateMs }`)
|
||||||
link(rel='prefetch' href='/static-assets/badges/not-found.png')
|
link(rel='prefetch' href=`/static-assets/badges/not-found.png?${ nowDateMs }`)
|
||||||
link(rel='prefetch' href='/static-assets/badges/error.png')
|
link(rel='prefetch' href=`/static-assets/badges/error.png?${ nowDateMs }`)
|
||||||
link(rel='stylesheet' href='/assets/fontawesome/css/all.css')
|
link(rel='stylesheet' href='/assets/fontawesome/css/all.css')
|
||||||
link(rel='stylesheet' href='/static-assets/instance.css')
|
link(rel='stylesheet' href=`/static-assets/instance.css?${ nowDateMs }`)
|
||||||
link(rel='modulepreload' href=`/assets/${clientEntry.file}`)
|
link(rel='modulepreload' href=`/assets/${clientEntry.file}`)
|
||||||
|
|
||||||
each href in clientEntry.css
|
each href in clientEntry.css
|
||||||
|
@ -78,7 +77,7 @@ html
|
||||||
br
|
br
|
||||||
| Please turn on your JavaScript
|
| Please turn on your JavaScript
|
||||||
div#splash
|
div#splash
|
||||||
img#splashIcon(src= splashIcon || '/static-assets/splash.png')
|
img#splashIcon(src= splashIcon || `/static-assets/splash.png?${ nowDateMs }`)
|
||||||
span#splashText
|
span#splashText
|
||||||
block randomMOTD
|
block randomMOTD
|
||||||
= randomMOTD
|
= randomMOTD
|
||||||
|
|
Loading…
Reference in New Issue