-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Only cache content in /_app #1416
Conversation
Just close this PR, if this is the indented behavior. |
Definitely not intended, this was an oversight. I don't think we want a separate |
could something like a .htaccess be a solution, where you can define some things caching/header rules out of the .js code? |
@Rich-Harris Also Sirv options would be great to configure. For example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware we had this issue. Thanks for fixing it
@Rich-Harris Should I closed this? Or should I revert the static folder and fix cache in assets folder instead? |
If we should see this as a patch, until a new, more configurable PR, is available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm except for the directory being hardcoded
I think I actually preferred the earlier iteration where there were two separate directories, but I will defer to Rich and am fine with this version. I do wonder if this also occurs on any of the other adapters or if they are free of this issue
There are errors when building with latest adapter-node. Should i add |
🦋 Changeset detectedLatest commit: 56c5453 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for sticking with this one. really close now!
packages/adapter-node/src/server.js
Outdated
immutable: true, | ||
setHeaders: (res, pathname, stats) => { | ||
// eslint-disable-next-line no-undef | ||
if (pathname.startsWith(`/${esbuild_app_dir}/`)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will require that the user not prefix or suffix config.kit.appDir
with /
. I think it'd be good to add either some sanitation or validation. E.g. we could automatically strip that prefix / suffix character. Or we could assert its value as we're doing for the base path in dc56d3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benmccann added check for leading slash + app_dir as root
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and app_dir can not be an empty string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But maybe these checks are unnecessary? SvelteKit doesn't work with app_dir: "/"
or app_dir: "/my_app_dir"
anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should probably be fixed in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still looks like it will not work if someone specifies config.kit.appDir
with a trailing slash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaa stupid me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benmccann fixed
Without this change, everything in the static folder will get the Cache-Control of
public,max-age=31536000,immutable
.This works well if you use the assets in html/svelte files (cache busting), but not so good for favicon.ico, robots.txt, etc.
Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
Changesets
pnpx changeset
and following the prompts