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.
This commit is contained in:
Bobby Wibowo 2018-04-27 04:30:11 +07:00
parent 00123b95d2
commit e01b007ea1
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
3 changed files with 3 additions and 5 deletions

View File

@ -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'

View File

@ -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}`
})
})

View File

@ -44,12 +44,11 @@
{% if enableDownload -%}
<div class="level-right">
<p class="level-item">
<a class="button is-primary is-outlined" title="Download album" href="../api/album/zip/{{ identifier }}?v={{ zipGeneratedAt }}">Download Album</a>
<a class="button is-primary is-outlined" title="Download album" href="../api/album/zip/{{ identifier }}?v={{ editedAt }}">Download Album</a>
</p>
</div>
{%- endif %}
</nav>
{#
{% if enableDownload -%}
<article class="message">
<div class="message-body">
@ -57,7 +56,6 @@
</div>
</article>
{%- endif %}
#}
<hr>
{% if files.length -%}
<div id="table" class="columns is-multiline is-mobile is-centered has-text-centered">