Add getFileUrl method to FileDestinationBase and provide cache buster

Created on 22 May 2024, about 1 month ago
Updated 21 June 2024, 12 days ago

Problem/Motivation

We're using the JSON File destination plugin to generate a JSON file in the public file system, to be consumed by a react app. When the dataset is updated the destination file path does not change. This leads to the file being served from a stale CDN cache.

Steps to reproduce

  • Use a CDN like AWS CloudFront
  • Create a dataset with JSON File destination
  • Warm the CDN cache for the destination file URL
  • Update the dataset
  • Access the destination file URL and notice it is served from cache.

Proposed resolution

  • Add a getFileUrl method to FileDestinationBase that returns a Url object
  • Add a query string to the Url with Url::setOption('query', $query)

Remaining tasks

Determine what the query string should be. Simple option is the filemtime of the destination file. Another option would be a hash of the file contents.

User interface changes

API changes

FileDestinationBase::getFileUrl

Data model changes

✨ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇦🇺Australia mstrelan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024