From e01b007ea1485455b99f1a92122f26773be9297e Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Fri, 27 Apr 2018 04:30:11 +0700 Subject: [PATCH] Updates Restored CDN warning to album pages. Turns out adding Page Rule to /api/album/zip/* with Cache Level set to Cache Everything and Origin Cache Control set to On will work just fine. The version string is still necessary to ensure that clients are downloading the very latest version of the archive though. Also last time I was using zipGeneratedAt timestamp, which was dumb, this time it is using editedAt timestamp, which was my original plan but kinda forgotten. --- controllers/albumsController.js | 2 +- routes/album.js | 2 +- views/album.njk | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/controllers/albumsController.js b/controllers/albumsController.js index 4d64377..1c5bc7b 100644 --- a/controllers/albumsController.js +++ b/controllers/albumsController.js @@ -193,7 +193,7 @@ albumsController.get = async (req, res, next) => { albumsController.generateZip = async (req, res, next) => { const download = (filePath, fileName) => { const headers = { 'Access-Control-Allow-Origin': '*' } - // Album page will append zipGeneratedAt timestamp to the download link by default + // Album page will append editedAt timestamp to the download link by default if (parseInt(req.query.v) > 0) { // Cache-Control header is useful when using CDN (max-age: 30 days) headers['Cache-Control'] = 'public, max-age=2592000, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800' diff --git a/routes/album.js b/routes/album.js index 16a823f..3197c82 100644 --- a/routes/album.js +++ b/routes/album.js @@ -62,7 +62,7 @@ routes.get('/a/:identifier', async (req, res, next) => { files, identifier, enableDownload: Boolean(config.uploads.generateZips), - zipGeneratedAt: album.zipGeneratedAt, + editedAt: album.editedAt, url: `${homeDomain}/a/${album.identifier}` }) }) diff --git a/views/album.njk b/views/album.njk index 7569133..00ba3ca 100644 --- a/views/album.njk +++ b/views/album.njk @@ -44,12 +44,11 @@ {% if enableDownload -%}

- Download Album + Download Album

{%- endif %} - {# {% if enableDownload -%}
@@ -57,7 +56,6 @@
{%- endif %} - #}
{% if files.length -%}