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

Embeds are triggering Netlify Function executions #989

Open
allanlasser opened this issue Dec 18, 2024 · 3 comments · Fixed by #987
Open

Embeds are triggering Netlify Function executions #989

allanlasser opened this issue Dec 18, 2024 · 3 comments · Fixed by #987

Comments

@allanlasser
Copy link
Member

allanlasser commented Dec 18, 2024

We need to optimize our SSR rules between Netlify and Cloudflare to ensure we're correctly caching our pages. Disabling SSR on embeds didn't improve this. It looks like Netlify is sending their default cache-control: no-cache header in responses.

Some approaches @eyeseast and I discussed:

  1. Enable prerendering on embed routes
  2. Overwriting the cache header with Cloudflare
  3. Re-enable SSR with more aggressive caching rules for embeds

Chris experimented by trying #2 and we've seen a reduction in cache misses, so this is likely a headers issue.

Our plan for now:

  1. Re-enable SSR on embeds
  2. Ensure we're sending correct headers from Netlify
  3. Check for correctness on our preview deployment, then merge
  4. Check for correctness post-merge through Cloudflare
@allanlasser allanlasser linked a pull request Dec 18, 2024 that will close this issue
@eyeseast eyeseast reopened this Dec 18, 2024
@eyeseast
Copy link
Collaborator

Leaving this open to continue optimization.

@eyeseast
Copy link
Collaborator

Test: curl -I 'https://embed.documentcloud.org/documents/25149282-signed-fair-fight-foundation-settlement-2024/?embed=1'

Result:

HTTP/2 200 
date: Wed, 18 Dec 2024 20:06:53 GMT
content-type: text/html
age: 32
cache-control: public,max-age=1200
cache-status: "Netlify Durable"; fwd=miss
cache-status: "Netlify Edge"; fwd=miss
etag: W/"19g4vu1-df"
last-modified: Fri, 18 Oct 2024 14:40:28 GMT
link: <../../_app/immutable/assets/0.D5nE7yh9.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/kit.mNZ0XOfn.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Toaster.CMmmKW7q.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/36.DNyy9aEA.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Viewer.C5vwTD04.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Button.dPlyuI0l.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/ContentLayout.DwHxIESo.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/SidebarItem.BL83LHyZ.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Sidebar.D-kjl1-r.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Note.D2QfWSFq.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Share.An5RfS3B.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Tooltip.BAxHM9cb.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Tab.C26ySnqn.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/FieldLabel.BDEEWmkN.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/PremiumBadge.DanCYG-s.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Text.C8Ooplcl.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/TextArea.CL3jMIy5.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Tip.Con_Lg2y.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Portal.DTw65T56.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/AccessLevel.CehukF8J.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Switch.BZFqeYt-.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Highlight.p8XD5pej.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Action.X-tUg2m0.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Menu.C4RMjm0M.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Error.BtBXjpfr.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Paginator.DoLOEDos.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Metadata.BUTDueJX.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/EmbedLayout.BOmH6B-3.css>; rel="preload";as="style"; nopush, <../../_app/immutable/assets/Logo.BwJ1SdBZ.css>; rel="preload";as="style"; nopush, <../../_app/immutable/entry/start.COQzYdHc.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/entry.YxvNaSRY.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/scheduler.BdM1oDmG.js>; rel="modulepreload"; nopush, <../../_app/immutable/entry/app.2ii0WBFu.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/preload-helper.XwPgvYjE.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/_sentry-release-injection-file.DPjUyyre.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/stores.DTMoS-pu.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/exports.4IMQAv6k.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/embed.BKoBf2dD.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/index.7CsyVNj-.js>; rel="modulepreload"; nopush, <../../_app/immutable/nodes/0.DB-1jR74.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/load.CCvL9lBB.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/runtime.Cu9QVecx.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/_commonjsHelpers.BEdbcXgv.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/config.BTn45BHH.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/globals.CW6ITl6F.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Toaster.BNHoewrZ.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/each.BUX38pqc.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/spread.BOtnHUHl.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/index.BzRhA7m2.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/X16.DPeNWtfU.js>; rel="modulepreload"; nopush, <../../_app/immutable/nodes/15.Ct-fSZJS.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/layout.BMiupbMD.js>; rel="modulepreload"; nopush, <../../_app/immutable/nodes/36.bN_AVwQq.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/index.DcosvwXj.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Viewer.BmLd6FXg.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/documents.X3EfT_84.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/accounts.D0wLIaHL.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/api.DBzwZyS2.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/SidebarExpand16.CrTZi1DC.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Button.BFMhtKuw.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Flex.BB1KWw3S.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/ContentLayout.BVOr6B9X.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/action.a650D8rg.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/SidebarItem.DyCZNR7G.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Sidebar.guQOmMv4.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Note.BM6sFYMO.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/browser.xpRik29m.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/purify.es.DYjbChdH.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Lock16.Cp1nFrIy.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Share.Djl4LwEW.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Organization24.C6Yc_5D3.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/File16.BIVu9SYq.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Tooltip.RjOFAgu-.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Tab.BzWTEXuz.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/navigation.os-V6O2h.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/storage.BHQKt6NC.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/FieldLabel.CcSXUPoT.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/PremiumBadge.6M9UzoeF.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Text.DnkcklTH.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/TextArea.Bt3ss7TQ.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Tip.C_UEtgbx.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Portal.Hx_KaEBB.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/forms.DTzMNM2d.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/AccessLevel.BWCstnK3.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Switch.DSCZeVWf.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/notes.M3LQgik4.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/People16.AX9UUx87.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/XCircle16.gOkdDXcK.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Highlight.C57L-kEz.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Question16.CqSlEL3p.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Action.CNLS7xdH.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Menu.BD2-HPSy.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Trash16.Bb_zR-f1.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/layout.CjJZ6QqO.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/search.DqA0RBxI.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Error.oQ-d_7do.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Paginator.Djips4GO.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Undo16.KpyzVfIV.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Metadata.CqLD5N9A.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/EmbedLayout.2pBzbCQ_.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Download16.CJ0NCsyQ.js>; rel="modulepreload"; nopush, <../../_app/immutable/chunks/Logo.DwuNl4-v.js>; rel="modulepreload"; nopush
netlify-vary: query
strict-transport-security: max-age=31536000
vary: Accept-Encoding
x-nf-request-id: 01JFDP1SZ0WYCVNDWEP0AR5KFA
x-sveltekit-page: true
cf-cache-status: HIT
server: cloudflare
cf-ray: 8f41c6ab0d8a8f7b-BOS
alt-svc: h3=":443"; ma=86400

Cloudflare is caching but Netlify isn't. That's better than before. I'm not sure if we can make it better.

@eyeseast
Copy link
Collaborator

Another facet of this: SvelteKit uses a __data.json endpoint to preload data, but these have a cache header of private, no-store, so it's creating a bunch of uncached requests.

More here: sveltejs/kit#10348

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

Successfully merging a pull request may close this issue.

2 participants