Zum Inhalt springen
verdict:

Astro 6.0.0-beta.18

preview

note: die Zusammenfassung und die Release Notes sind auf Englisch

note: keine Zusammenfassung für dieses ältere Release

Wir fassen die neueren Releases zusammen. Die originalen Release Notes dieser Version stehen hier unten.

release-notesgithub.com/withastro/astro · 210 Zeilen
  1. ### Major Changes
  2. - [#15668](https://github.com/withastro/astro/pull/15668) [`1118ac4`](https://github.com/withastro/astro/commit/1118ac4f299341e15061e8a4e6e8423071c4d41c) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Changes TypeScript configuration - ([v6 upgrade guidance](https://v6.docs.astro.build/en/guides/upgrade-to/v6/#changed-typescript-configuration))
  3. - [#15726](https://github.com/withastro/astro/pull/15726) [`6f19ecc`](https://github.com/withastro/astro/commit/6f19ecc35adfb2ddaabbba2269630f95c13f5a57) Thanks [@ocavue](https://github.com/ocavue)! - Updates dependency `shiki` to v4
  4. Check [Shiki's upgrade guide](https://shiki.style/blog/v4).
  5. ### Minor Changes
  6. - [#15694](https://github.com/withastro/astro/pull/15694) [`66449c9`](https://github.com/withastro/astro/commit/66449c930e73e9a58ce547b9c32635a98a310966) Thanks [@matthewp](https://github.com/matthewp)! - Adds `preserveBuildClientDir` option to adapter features
  7. Adapters can now opt in to preserving the client/server directory structure for static builds by setting `preserveBuildClientDir: true` in their adapter features. When enabled, static builds will output files to `build.client` instead of directly to `outDir`.
  8. This is useful for adapters that require a consistent directory structure regardless of the build output type, such as deploying to platforms with specific file organization requirements.
  9. ```js
  10. // my-adapter/index.js
  11. export default function myAdapter() {
  12. return {
  13. name: 'my-adapter',
  14. hooks: {
  15. 'astro:config:done': ({ setAdapter }) => {
  16. setAdapter({
  17. name: 'my-adapter',
  18. adapterFeatures: {
  19. buildOutput: 'static',
  20. preserveBuildClientDir: true,
  21. },
  22. });
  23. },
  24. },
  25. };
  26. }
  27. ```
  28. - [#15579](https://github.com/withastro/astro/pull/15579) [`08437d5`](https://github.com/withastro/astro/commit/08437d531e31b79a42333a9f7aabaa9fe646ce4f) Thanks [@ascorbic](https://github.com/ascorbic)! - Adds two new experimental flags for a Route Caching API and further configuration-level Route Rules for controlling SSR response caching.
  29. Route caching gives you a platform-agnostic way to cache server-rendered responses, based on web standard cache headers. You set caching directives in your routes using `Astro.cache` (in `.astro` pages) or `context.cache` (in API routes and middleware), and Astro translates them into the appropriate headers or runtime behavior depending on your adapter. You can also define cache rules for routes declaratively in your config using `experimental.routeRules`, without modifying route code.
  30. This feature requires on-demand rendering. Prerendered pages are already static and do not use route caching.
  31. #### Getting started
  32. Enable the feature by configuring `experimental.cache` with a cache provider in your Astro config:
  33. ```js
  34. // astro.config.mjs
  35. import { defineConfig } from 'astro/config';
  36. import node from '@astrojs/node';
  37. import { memoryCache } from 'astro/config';
  38. export default defineConfig({
  39. adapter: node({ mode: 'standalone' }),
  40. experimental: {
  41. cache: {
  42. provider: memoryCache(),
  43. },
  44. },
  45. });
  46. ```
  47. #### Using `Astro.cache` and `context.cache`
  48. In `.astro` pages, use `Astro.cache.set()` to control caching:
  49. ```astro
  50. ---
  51. // src/pages/index.astro
  52. Astro.cache.set({
  53. maxAge: 120, // Cache for 2 minutes
  54. swr: 60, // Serve stale for 1 minute while revalidating
  55. tags: ['home'], // Tag for targeted invalidation
  56. });
  57. ---
  58. <html><body>Cached page</body></html>
  59. ```
  60. In API routes and middleware, use `context.cache`:
  61. ```ts
  62. // src/pages/api/data.ts
  63. export function GET(context) {
  64. context.cache.set({
  65. maxAge: 300,
  66. tags: ['api', 'data'],
  67. });
  68. return Response.json({ ok: true });
  69. }
  70. ```
  71. #### Cache options
  72. `cache.set()` accepts the following options:
  73. - **`maxAge`** (number): Time in seconds the response is considered fresh.
  74. - **`swr`** (number): Stale-while-revalidate window in seconds. During this window, stale content is served while a fresh response is generated in the background.
  75. - **`tags`** (string\[]): Cache tags for targeted invalidation. Tags accumulate across multiple `set()` calls within a request.
  76. - **`lastModified`** (Date): When multiple `set()` calls provide `lastModified`, the most recent date wins.
  77. - **`etag`** (string): Entity tag for conditional requests.
  78. Call `cache.set(false)` to explicitly opt out of caching for a request.
  79. Multiple calls to `cache.set()` within a single request are merged: scalar values use last-write-wins, `lastModified` uses most-recent-wins, and tags accumulate.
  80. #### Invalidation
  81. Purge cached entries by tag or path using `cache.invalidate()`:
  82. ```ts
  83. // Invalidate all entries tagged 'data'
  84. await context.cache.invalidate({ tags: ['data'] });
  85. // Invalidate a specific path
  86. await context.cache.invalidate({ path: '/api/data' });
  87. ```
  88. #### Config-level route rules
  89. Use `experimental.routeRules` to set default cache options for routes without modifying route code. Supports Nitro-style shortcuts for ergonomic configuration:
  90. ```js
  91. import { memoryCache } from 'astro/config';
  92. export default defineConfig({
  93. experimental: {
  94. cache: {
  95. provider: memoryCache(),
  96. },
  97. routeRules: {
  98. // Shortcut form (Nitro-style)
  99. '/api/*': { swr: 600 },
  100. // Full form with nested cache
  101. '/products/*': { cache: { maxAge: 3600, tags: ['products'] } },
  102. },
  103. },
  104. });
  105. ```
  106. Route patterns support static paths, dynamic parameters (`[slug]`), and rest parameters (`[...path]`). Per-route `cache.set()` calls merge with (and can override) the config-level defaults.
  107. You can also read the current cache state via `cache.options`:
  108. ```ts
  109. const { maxAge, swr, tags } = context.cache.options;
  110. ```
  111. #### Cache providers
  112. Cache behavior is determined by the configured **cache provider**. There are two types:
  113. - **CDN providers** set response headers (e.g. `CDN-Cache-Control`, `Cache-Tag`) and let the CDN handle caching. Astro strips these headers before sending the response to the client.
  114. - **Runtime providers** implement `onRequest()` to intercept and cache responses in-process, adding an `X-Astro-Cache` header (HIT/MISS/STALE) for observability.
  115. #### Built-in memory cache provider
  116. Astro includes a built-in, in-memory LRU runtime cache provider. Import `memoryCache` from `astro/config` to configure it.
  117. Features:
  118. - In-memory LRU cache with configurable max entries (default: 1000)
  119. - Stale-while-revalidate support
  120. - Tag-based and path-based invalidation
  121. - `X-Astro-Cache` response header: `HIT`, `MISS`, or `STALE`
  122. - Query parameter sorting for better hit rates (`?b=2&a=1` and `?a=1&b=2` hit the same entry)
  123. - Common tracking parameters (`utm_*`, `fbclid`, `gclid`, etc.) excluded from cache keys by default
  124. - `Vary` header support — responses that set `Vary` automatically get separate cache entries per variant
  125. - Configurable query parameter filtering via `query.exclude` (glob patterns) and `query.include` (allowlist)
  126. For more information on enabling and using this feature in your project, see the [Experimental Route Caching docs](https://docs.astro.build/en/reference/experimental-flags/route-caching/).
  127. For a complete overview and to give feedback on this experimental API, see the [Route Caching RFC](https://github.com/withastro/roadmap/pull/1245).
  128. ### Patch Changes
  129. - [#15721](https://github.com/withastro/astro/pull/15721) [`e6e146c`](https://github.com/withastro/astro/commit/e6e146cb0ac535e21c26f6b1c3d2f65be9dbdb4c) Thanks [@matthewp](https://github.com/matthewp)! - Fixes action route handling to return 404 for requests to prototype method names like `constructor` or `toString` used as action paths
  130. - [#15704](https://github.com/withastro/astro/pull/15704) [`862d77b`](https://github.com/withastro/astro/commit/862d77bd6c3e05e20fd58293f9577ae685a9b8c9) Thanks [@umutkeltek](https://github.com/umutkeltek)! - Fixes i18n fallback middleware intercepting non-404 responses
  131. The fallback middleware was triggering for all responses with status >= 300, including legitimate 3xx redirects, 403 forbidden, and 5xx server errors. This broke auth flows and form submissions on localized server routes. The fallback now correctly only triggers for 404 (page not found) responses.
  132. - [#15703](https://github.com/withastro/astro/pull/15703) [`829182b`](https://github.com/withastro/astro/commit/829182bbdfc307a005aea00ac8c00923f76efb08) Thanks [@matthewp](https://github.com/matthewp)! - Fixes server islands returning a 500 error in dev mode for adapters that do not set `adapterFeatures.buildOutput` (e.g. `@astrojs/netlify`)
  133. - [#15749](https://github.com/withastro/astro/pull/15749) [`573d188`](https://github.com/withastro/astro/commit/573d188de9a7e6635f24004291c3e71e0ddc7a7a) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes a bug that caused `session.regenerate()` to silently lose session data
  134. Previously, regenerated session data was not saved under the new session ID unless `set()` was also called.
  135. - [#15685](https://github.com/withastro/astro/pull/15685) [`1a323e5`](https://github.com/withastro/astro/commit/1a323e5c64c7c23212ed80546f593d930115d55c) Thanks [@jcayzac](https://github.com/jcayzac)! - Fix regression where SVG images in content collection `image()` fields could not be rendered as inline components. This behavior is now restored while preserving the TLA deadlock fix.
  136. - [#15740](https://github.com/withastro/astro/pull/15740) [`c5016fc`](https://github.com/withastro/astro/commit/c5016fc86c4928a26b49dbe144b5569d5d89ac04) Thanks [@matthewp](https://github.com/matthewp)! - Removes an escape hatch that skipped attribute escaping for URL values containing `&`, ensuring all dynamic attribute values are consistently escaped
  137. - [#15744](https://github.com/withastro/astro/pull/15744) [`fabb710`](https://github.com/withastro/astro/commit/fabb710c2514c5a1298e002dd961a1d79686f021) Thanks [@matthewp](https://github.com/matthewp)! - Fixes cookie handling during error page rendering to ensure cookies set by middleware are consistently included in the response
  138. - [#15742](https://github.com/withastro/astro/pull/15742) [`9d9699c`](https://github.com/withastro/astro/commit/9d9699c04aba7524bd3c8e1b8303691db19fa5bd) Thanks [@matthewp](https://github.com/matthewp)! - Hardens `clientAddress` resolution to respect `security.allowedDomains` for `X-Forwarded-For`, consistent with the existing handling of `X-Forwarded-Host`, `X-Forwarded-Proto`, and `X-Forwarded-Port`. The `X-Forwarded-For` header is now only used to determine `Astro.clientAddress` when the request's host has been validated against an `allowedDomains` entry. Without a matching domain, `clientAddress` falls back to the socket's remote address.
  139. - [#15696](https://github.com/withastro/astro/pull/15696) [`a9fd221`](https://github.com/withastro/astro/commit/a9fd221bda99db4660c241c494b6d3225eb4e51d) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Fixes images not working in MDX when using the Cloudflare adapter in certain cases
  140. - [#15693](https://github.com/withastro/astro/pull/15693) [`4db2089`](https://github.com/withastro/astro/commit/4db2089a8e01cdb298c49f61817daf240ae07fa5) Thanks [@ArmandPhilippot](https://github.com/ArmandPhilippot)! - Fixes the links to Astro Docs to match the v6 structure.
  141. - [#15717](https://github.com/withastro/astro/pull/15717) [`4000aaa`](https://github.com/withastro/astro/commit/4000aaa2d361cbfc9bbf280a9b0e78e6db167945) Thanks [@matthewp](https://github.com/matthewp)! - Ensures that URLs with multiple leading slashes (e.g. `//admin`) are normalized to a single slash before reaching middleware, so that pathname checks like `context.url.pathname.startsWith('/admin')` work consistently regardless of the request URL format
  142. - [#15752](https://github.com/withastro/astro/pull/15752) [`918d394`](https://github.com/withastro/astro/commit/918d3949f3b92b1ae46dadd77cfb1404869c50bd) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes an issue where a session ID from a cookie with no matching server-side data was accepted as-is. The session now generates a new ID when the cookie value has no corresponding storage entry.
  143. - [#15743](https://github.com/withastro/astro/pull/15743) [`3b4252a`](https://github.com/withastro/astro/commit/3b4252a82a937fccbfd433d90a93ad524a7a6f7b) Thanks [@matthewp](https://github.com/matthewp)! - Hardens config-based redirects with catch-all parameters to prevent producing protocol-relative URLs (e.g. `//example.com`) in the `Location` header
  144. - [#15718](https://github.com/withastro/astro/pull/15718) [`14f37b8`](https://github.com/withastro/astro/commit/14f37b80aa2bd086cf31feccd5016c73a09822ae) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes a case where internal headers may leak when rendering error pages
  145. - Updated dependencies \[[`6f19ecc`](https://github.com/withastro/astro/commit/6f19ecc35adfb2ddaabbba2269630f95c13f5a57), [`f94d3c5`](https://github.com/withastro/astro/commit/f94d3c5313e5a7576cf2cb316a85d68d335a188f)]:
  146. - @astrojs/markdown-remark@7.0.0-beta.9

auf github ansehenimported 2026-09-28 über npm