@sveltejs/kit 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -25,7 +25,7 @@
25
25
  "undici": "5.14.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@playwright/test": "^1.28.1",
28
+ "@playwright/test": "^1.29.2",
29
29
  "@types/connect": "^3.4.35",
30
30
  "@types/marked": "^4.0.7",
31
31
  "@types/mime": "^3.0.1",
@@ -189,6 +189,7 @@ export function get_build_compile_config({ config, input, ssr, outDir }) {
189
189
  output: {
190
190
  entryFileNames: `${prefix}/workers/[name]-[hash].js`,
191
191
  chunkFileNames: `${prefix}/workers/chunks/[name]-[hash].js`,
192
+ assetFileNames: `${prefix}/workers/assets/[name]-[hash][extname]`,
192
193
  hoistTransitiveImports: false
193
194
  }
194
195
  }
@@ -46,6 +46,7 @@ export function serialize_data(fetched, filter, prerendering = false) {
46
46
 
47
47
  let cache_control = null;
48
48
  let age = null;
49
+ let vary = false;
49
50
 
50
51
  for (const [key, value] of fetched.response.headers) {
51
52
  if (filter(key, value)) {
@@ -54,6 +55,7 @@ export function serialize_data(fetched, filter, prerendering = false) {
54
55
 
55
56
  if (key === 'cache-control') cache_control = value;
56
57
  if (key === 'age') age = value;
58
+ if (key === 'vary') vary = true;
57
59
  }
58
60
 
59
61
  const payload = {
@@ -75,7 +77,11 @@ export function serialize_data(fetched, filter, prerendering = false) {
75
77
  attrs.push(`data-hash=${escape_html_attr(hash(fetched.request_body))}`);
76
78
  }
77
79
 
78
- if (!prerendering && fetched.method === 'GET' && cache_control) {
80
+ // Compute the time the response should be cached, taking into account max-age and age.
81
+ // Do not cache at all if a vary header is present, as this indicates that the cache is
82
+ // likely to get busted. It would also mean we'd have to add more logic to computing the
83
+ // selector on the client which results in more code for 99% of people for the 1% who use vary.
84
+ if (!prerendering && fetched.method === 'GET' && cache_control && !vary) {
79
85
  const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control);
80
86
  if (match) {
81
87
  const ttl = +match[1] - +(age ?? '0');