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

Remove cache control headers #9832

Merged
merged 7 commits into from
May 24, 2023
Merged

Remove cache control headers #9832

merged 7 commits into from
May 24, 2023

Conversation

AMBacelar
Copy link
Contributor

Who is this for?

Platform, by making this change to the cache-control headers, we allow users to access cached resources, instead of forcing the platform to constantly repeat the same request multiple times and taking the service down

What is it doing for them?

for now, removing all the no-cache responses, to be fine tuned at a later time, Amazon Cloudfront does have it's own cache control settings, so we will need to see what the behaviour ends up being.

note: as stated here you cannot set Cache-Control headers in the next.config file so I had to set it in all the pages files individually.

@AMBacelar AMBacelar self-assigned this May 23, 2023
@AMBacelar AMBacelar requested a review from a team May 23, 2023 08:40
@github-actions
Copy link

github-actions bot commented May 23, 2023

Size Change: +3 B (0%)

Total Size: 1.08 MB

Filename Size Change
catalogue/webapp/.next/static/chunks/pages/concepts/[conceptId]-afcfda67956e6c61.js 0 B -5.63 kB (removed) 🏆
catalogue/webapp/.next/static/chunks/pages/search-01f959524d32ec5f.js 0 B -3.72 kB (removed) 🏆
catalogue/webapp/.next/static/chunks/pages/search/images-c52351abe2ceeaf6.js 0 B -1.27 kB (removed) 🏆
catalogue/webapp/.next/static/chunks/pages/search/stories-689166761a140dbf.js 0 B -5.92 kB (removed) 🏆
catalogue/webapp/.next/static/chunks/pages/search/works-66a2d3dbc848e940.js 0 B -6.31 kB (removed) 🏆
catalogue/webapp/.next/static/chunks/pages/works/[workId]/items-d4c21a558bc94bd7.js 0 B -2.4 kB (removed) 🏆
content/webapp/.next/static/chunks/pages/articles/[articleId]-6c8178745a1d3ccf.js 0 B -4.15 kB (removed) 🏆
content/webapp/.next/static/chunks/pages/books/[bookId]-41ebca56c0bce755.js 0 B -1.5 kB (removed) 🏆
content/webapp/.next/static/chunks/pages/events/[eventId]-975585a612c14041.js 0 B -6.72 kB (removed) 🏆
content/webapp/.next/static/chunks/pages/guides/exhibitions/[id]/[type]-5d197dda65c8d03b.js 0 B -6.42 kB (removed) 🏆
content/webapp/.next/static/chunks/pages/homepage-835e5f8f6e512c51.js 0 B -3.62 kB (removed) 🏆
content/webapp/.next/static/chunks/pages/series/[seriesId]-a8ead53d44a3eb80.js 0 B -4.01 kB (removed) 🏆
content/webapp/.next/static/chunks/pages/stories-640eab0d4b6eabdb.js 0 B -1.56 kB (removed) 🏆
content/webapp/.next/static/chunks/pages/whats-on-0a4e74321a6b9404.js 0 B -5.32 kB (removed) 🏆
catalogue/webapp/.next/static/chunks/pages/concepts/[conceptId]-794546140d641b85.js 5.63 kB +5.63 kB (new file) 🆕
catalogue/webapp/.next/static/chunks/pages/search-495900327b0ed2b6.js 3.72 kB +3.72 kB (new file) 🆕
catalogue/webapp/.next/static/chunks/pages/search/images-a4de5f45b8917eae.js 1.27 kB +1.27 kB (new file) 🆕
catalogue/webapp/.next/static/chunks/pages/search/stories-b41a5b6c84a55cb2.js 5.92 kB +5.92 kB (new file) 🆕
catalogue/webapp/.next/static/chunks/pages/search/works-30d710e0715f1c39.js 6.31 kB +6.31 kB (new file) 🆕
catalogue/webapp/.next/static/chunks/pages/works/[workId]/items-a6f1996a9c863120.js 2.4 kB +2.4 kB (new file) 🆕
content/webapp/.next/static/chunks/pages/articles/[articleId]-7f683d4016e5d2c1.js 4.15 kB +4.15 kB (new file) 🆕
content/webapp/.next/static/chunks/pages/books/[bookId]-b7b508205a22a777.js 1.5 kB +1.5 kB (new file) 🆕
content/webapp/.next/static/chunks/pages/events/[eventId]-bce8686d4a00f9a5.js 6.72 kB +6.72 kB (new file) 🆕
content/webapp/.next/static/chunks/pages/guides/exhibitions/[id]/[type]-ee0d462a8a202f25.js 6.42 kB +6.42 kB (new file) 🆕
content/webapp/.next/static/chunks/pages/homepage-6094ff666b394d6f.js 3.63 kB +3.63 kB (new file) 🆕
content/webapp/.next/static/chunks/pages/series/[seriesId]-40ff5d19005f9c2d.js 4.01 kB +4.01 kB (new file) 🆕
content/webapp/.next/static/chunks/pages/stories-82e221c5689be52b.js 1.56 kB +1.56 kB (new file) 🆕
content/webapp/.next/static/chunks/pages/whats-on-9bf1ddb739b9535c.js 5.32 kB +5.32 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
catalogue/webapp/.next/static/chunks/00a8a139.76f7b4400ec17d92.js 58 kB
catalogue/webapp/.next/static/chunks/101-531201426fbb9652.js 3.09 kB
catalogue/webapp/.next/static/chunks/103-0a37f0001bcc0f8d.js 2.5 kB
catalogue/webapp/.next/static/chunks/223.95accb6dcdb27811.js 1.73 kB
catalogue/webapp/.next/static/chunks/385-981aba5bf1631b4c.js 3.35 kB
catalogue/webapp/.next/static/chunks/394-6e5afc716c4f6e45.js 5.9 kB
catalogue/webapp/.next/static/chunks/428-40f42f49d0256255.js 26.2 kB
catalogue/webapp/.next/static/chunks/491-785105f8f4b17151.js 6.74 kB
catalogue/webapp/.next/static/chunks/519-a403c235517e5b34.js 10.2 kB
catalogue/webapp/.next/static/chunks/536-d6f7512f7eafb591.js 3.14 kB
catalogue/webapp/.next/static/chunks/577-e9d971fd51e7fb8c.js 3.65 kB
catalogue/webapp/.next/static/chunks/583-02877c3ec8311a16.js 18.5 kB
catalogue/webapp/.next/static/chunks/677.a0884a27fb537187.js 19.9 kB
catalogue/webapp/.next/static/chunks/730-b0015715faafeb20.js 3.75 kB
catalogue/webapp/.next/static/chunks/768-8dfb2cfdbd47c72c.js 3.73 kB
catalogue/webapp/.next/static/chunks/800-a72589ee5ba3ff2d.js 4.44 kB
catalogue/webapp/.next/static/chunks/framework-19f3649580393c10.js 45.2 kB
catalogue/webapp/.next/static/chunks/main-ec57c2d42fe613c3.js 33.6 kB
catalogue/webapp/.next/static/chunks/pages/_app-ba6d993fd4b6fa33.js 107 kB
catalogue/webapp/.next/static/chunks/pages/_error-b07a4a98ea140b1b.js 308 B
catalogue/webapp/.next/static/chunks/pages/404-d69ec1c91b152fba.js 249 B
catalogue/webapp/.next/static/chunks/pages/works/[workId]-b197216320309d0e.js 326 B
catalogue/webapp/.next/static/chunks/pages/works/[workId]/download-688b11384476e31a.js 4.98 kB
catalogue/webapp/.next/static/chunks/pages/works/[workId]/images-56f7ce9af42cb026.js 836 B
catalogue/webapp/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js 31 kB
catalogue/webapp/.next/static/chunks/webpack-fbbf5871f3c236a3.js 1.69 kB
content/webapp/.next/static/chunks/127-bc8df33fed5e8fd4.js 6.12 kB
content/webapp/.next/static/chunks/268-38f09afbaedf3e49.js 4.63 kB
content/webapp/.next/static/chunks/314-ab460e19713a4711.js 3.55 kB
content/webapp/.next/static/chunks/510-bd50c0c622d645f9.js 20.1 kB
content/webapp/.next/static/chunks/577-f9a593060b85c45a.js 3.5 kB
content/webapp/.next/static/chunks/641-304a2479983fd194.js 4.25 kB
content/webapp/.next/static/chunks/651-c92edd682b8928f5.js 2.5 kB
content/webapp/.next/static/chunks/652-188568690a3594f6.js 6.41 kB
content/webapp/.next/static/chunks/677.a0884a27fb537187.js 19.9 kB
content/webapp/.next/static/chunks/696.0dce4c1f971a627e.js 1.25 kB
content/webapp/.next/static/chunks/framework-19f3649580393c10.js 45.2 kB
content/webapp/.next/static/chunks/main-6287a0b370d3b7fa.js 27 kB
content/webapp/.next/static/chunks/pages/_app-7ca01ae76d6e2901.js 108 kB
content/webapp/.next/static/chunks/pages/_error-1cb1372ef9ad3eda.js 329 B
content/webapp/.next/static/chunks/pages/404-c8f511e910c105b7.js 257 B
content/webapp/.next/static/chunks/pages/500-ed13545909bf5f32.js 256 B
content/webapp/.next/static/chunks/pages/articles-a86899a76ba82449.js 2.89 kB
content/webapp/.next/static/chunks/pages/books-e1e6cfeba1e83ddd.js 2.9 kB
content/webapp/.next/static/chunks/pages/collections-705671c43c3742a4.js 2.1 kB
content/webapp/.next/static/chunks/pages/covid-welcome-back-726d6d86a65cb6df.js 11.3 kB
content/webapp/.next/static/chunks/pages/event-series/[eventSeriesId]-168730c26e99351b.js 1.95 kB
content/webapp/.next/static/chunks/pages/events-047e156947017b4a.js 3.01 kB
content/webapp/.next/static/chunks/pages/exhibitions-91fd15db67c6b48a.js 3.21 kB
content/webapp/.next/static/chunks/pages/exhibitions/[exhibitionId]-884fb946cd86f9db.js 4.08 kB
content/webapp/.next/static/chunks/pages/guides-d6564cbb8ffc2b52.js 4.16 kB
content/webapp/.next/static/chunks/pages/guides/[pageId]-f0cddba2337ca734.js 2.02 kB
content/webapp/.next/static/chunks/pages/guides/exhibitions-03824de043313263.js 2.98 kB
content/webapp/.next/static/chunks/pages/guides/exhibitions/[id]-808004db2d630765.js 3.52 kB
content/webapp/.next/static/chunks/pages/newsletter-99644b27da64bc29.js 3.07 kB
content/webapp/.next/static/chunks/pages/pages/[pageId]-a7a2a8df44e7ed44.js 1.99 kB
content/webapp/.next/static/chunks/pages/projects/[pageId]-ce3e4662e46dc793.js 2.02 kB
content/webapp/.next/static/chunks/pages/seasons/[seasonId]-d65740e3fb71c2da.js 1.43 kB
content/webapp/.next/static/chunks/pages/stories/[contentType]-66ae0ef6165e5b73.js 2.94 kB
content/webapp/.next/static/chunks/pages/visit-us-3a81ae40bf8adde3.js 2.43 kB
content/webapp/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js 31 kB
content/webapp/.next/static/chunks/webpack-25efc9cbcdd5c753.js 1.6 kB
identity/webapp/.next/static/chunks/374.94537fd117195c86.js 2.48 kB
identity/webapp/.next/static/chunks/432.fa29da5acdb8e0b1.js 744 B
identity/webapp/.next/static/chunks/442-29780463d96993ea.js 8.35 kB
identity/webapp/.next/static/chunks/644-6570c06909c1478e.js 5.92 kB
identity/webapp/.next/static/chunks/677.a0884a27fb537187.js 19.9 kB
identity/webapp/.next/static/chunks/740-b2611254444f9948.js 3.89 kB
identity/webapp/.next/static/chunks/framework-19f3649580393c10.js 45.2 kB
identity/webapp/.next/static/chunks/main-d973a3979032d64a.js 32.2 kB
identity/webapp/.next/static/chunks/pages/_app-31644233a7f17a9c.js 103 kB
identity/webapp/.next/static/chunks/pages/_error-8e82953fa241027d.js 1.42 kB
identity/webapp/.next/static/chunks/pages/delete-requested-409a4b8902f36a9b.js 4.03 kB
identity/webapp/.next/static/chunks/pages/error-35a4e3c277bda2ac.js 1.58 kB
identity/webapp/.next/static/chunks/pages/index-38efbf2a93b69bdf.js 12.2 kB
identity/webapp/.next/static/chunks/pages/registration-575a754d97a831b5.js 1.31 kB
identity/webapp/.next/static/chunks/pages/success-a7cf80eb2653b350.js 432 B
identity/webapp/.next/static/chunks/pages/validated-5ad68b23a64bbbfc.js 4.6 kB
identity/webapp/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js 31 kB
identity/webapp/.next/static/chunks/webpack-713796e2734212eb.js 1.81 kB

compressed-size-action

Copy link
Contributor

@jamieparkinson jamieparkinson left a comment

Choose a reason for hiding this comment

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

Difficult one with the default value! I had said that we shouldn't set a max-age but that doesn't tell us what we should set... I see why you went with public, but on the other hand MDN tells us that:

If a request doesn't have an Authorization header, or you are already using s-maxage or must-revalidate in the response, then you don't need to use public.

which makes our intentions confusing when reading the code. My suggestion is in 2 parts:

  1. We should do this regardless: encapsulate the logic of what we want to do with the cache headers, so it doesn't have to be duplicated in each getServerSideProps - this also means we can document it better.
    That probably looks like a function setCacheControl(res: ServerResponse): void that lives somewhere in common and can just be called in each getServerSideProps like setCacheControl(context.res).
  2. Then thinking about what to do in that function... I was thinking we'd have to choose a max-age, but your PR title gave me another idea! How about we just do res.removeHeader('Cache-Control') - no decisions about defaults necessary! When you do this, let's add a comment explaining our reasoning (ie the fact that Next sets defaults and the fact that caching is handled in CloudFront), and let's link to the CloudFront docs and our existing cache policies

The one caveat with my suggestion (2) is if Next.js adds the header back in - we'll need to check to see whether it does that, and if it does I think, on balance, and reading the CloudFront docs, we should add a max-age of an hour in rather than relying on default behaviours from not setting it. (I know I've changed my mind on that, sorry!)

Copy link
Contributor

@jamieparkinson jamieparkinson left a comment

Choose a reason for hiding this comment

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

Just a bit more detail in this comment to justify our statements, otherwise this is good!

common/utils/setCacheControl.ts Show resolved Hide resolved
@AMBacelar AMBacelar force-pushed the remove-cache-control-headers branch from 7fd0d2d to 1519715 Compare May 24, 2023 10:20
@AMBacelar AMBacelar merged commit edd7436 into main May 24, 2023
@AMBacelar AMBacelar deleted the remove-cache-control-headers branch May 24, 2023 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants