Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Browser side Azure static assets caching #56

Merged
merged 39 commits into from
Jan 23, 2025
Merged

Conversation

cooper667
Copy link
Collaborator

@cooper667 cooper667 commented Dec 31, 2024

Description

By default, CKAN caches badly The settings it give us for caching are fairly blunt, but we can set some things at the CDN level. It sets must-revalidate on things, which according to the spec:

The must-revalidate directive ought to be used by servers if and only if failure to validate a request could cause incorrect operation, such as a silently unexecuted financial transaction.

And no-cache, which doesn't technically mean don't cache, but apparently some browsers DO interpret it as that

The no-cache response directive, in its unqualified form (without an argument), indicates that the response MUST NOT be used to satisfy any other request without forwarding it for validation and receiving a successful response

So we probably don't need that on...fonts etc.

This PR allows static assets to be cached browser side. This helps a lot when navigating pages and generally using the site as it makes the user experience quicker and removes some load from the server. We cache for a long time, and invalidation is handled by hashes in the names of the assets (we may want to consider how we handle images if we have some that change frequently)

The list of extensions cached is:

js
css
woff
svg
jpg
woff2

We likely want to do similar with AWS/Cloudflare

The next step is caching in our CDNs too to help first load on these requests, this requires some CKAN config tho.

Testing (delete if not applicable)

Deployed on AfroStaging

Checklist

Put an x in the boxes that apply to this pull request (you can also fill these out after opening the pull request).
You may not need to check all boxes.

  • The GitHub ticket for this issue has been updated to "Ready to Review" or equivalent.
  • I have developed these changes in discussion with the appropriate project manager.
  • My code follows the general Fjelltopp documentation (see Confluence).
  • I have made corresponding changes to the Fjelltopp documentation (see Confluence).
  • I have rebased this branch with master.
  • New dependency changes have been committed.
  • I have added automated tests that prove my fix is effective or that my feature works.
  • New and existing tests pass locally with my changes.
  • My changes generate no new warnings.
  • I have performed a self-review of my own code.
  • I have assigned at least one reviewer.
  • I have assigned at least one label to this PR: "patch", "minor", "major".

@cooper667 cooper667 self-assigned this Dec 31, 2024
Base automatically changed from azure_waf to master January 23, 2025 09:56
@cooper667 cooper667 marked this pull request as ready for review January 23, 2025 09:58
Copy link
Member

@ChasNelson1990 ChasNelson1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've used staging a lot to test the WAF and nothing seems broken!

@cooper667 cooper667 merged commit 9756fba into master Jan 23, 2025
@cooper667 cooper667 deleted the azure_static_assets branch January 23, 2025 10:05
Copy link

🚀 [bumpr] Bumped! New version:v3.3.0 Changes:v3.2.0...v3.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants