惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Hacker News: Ask HN
Hacker News: Ask HN
N
News and Events Feed by Topic
Forbes - Security
Forbes - Security
The Last Watchdog
The Last Watchdog
TaoSecurity Blog
TaoSecurity Blog
Schneier on Security
Schneier on Security
SecWiki News
SecWiki News
V
Vulnerabilities – Threatpost
Project Zero
Project Zero
O
OpenAI News
W
WeLiveSecurity
Security Archives - TechRepublic
Security Archives - TechRepublic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
H
Hacker News: Front Page
Cisco Talos Blog
Cisco Talos Blog
Spread Privacy
Spread Privacy
Help Net Security
Help Net Security
P
Privacy & Cybersecurity Law Blog
K
Kaspersky official blog
S
Security @ Cisco Blogs
Latest news
Latest news
AWS News Blog
AWS News Blog
U
Unit 42
Martin Fowler
Martin Fowler
阮一峰的网络日志
阮一峰的网络日志
S
Secure Thoughts
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Know Your Adversary
Know Your Adversary
Scott Helme
Scott Helme
博客园 - 司徒正美
B
Blog RSS Feed
C
Check Point Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
Docker
Google Online Security Blog
Google Online Security Blog
Jina AI
Jina AI
aimingoo的专栏
aimingoo的专栏
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Last Week in AI
Last Week in AI
月光博客
月光博客
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
SegmentFault 最新的问题
NISL@THU
NISL@THU
T
The Blog of Author Tim Ferriss
C
Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
小众软件
小众软件

The Astro Blog

Astro 6.4 Astro 6.3 Starlight 0.39 Astro 6.2 What's new in Astro - April 2026 What's new in Astro - March 2026 Astro 6.1 CloudCannon Joins Astro as an Official CMS Partner Astro 6.0 What's new in Astro - February 2026 What's new in Astro - January 2026 Astro 5.17 Supporting the future of Astro The Astro Technology Company joins Cloudflare Astro 6 Beta What's new in Astro - December 2025 What's new in Astro - November 2025 Astro 5.16 Stainless Sponsors Astro, Launches Astro-Powered Docs Platform What's new in Astro - October 2025 Astro 5.15 Spirit of Astro: meet the winning designs What's new in Astro - September 2025 Astro 5.14 Cloudflare Donates $150,000 to Support Astro's Open Source Mission Webflow Donates $150,000 to Support Astro's Open Source Mission Mux: Our Official Video Partner Unleashing creativity: How CodeTV built a video streaming platform with Astro and Mux | Astro What's new in Astro - August 2025 Astro 5.13 What's new in Astro - July 2025 Astro 5.12 Starlight 0.35 Astro 5.11 What's new in Astro - June 2025 Live Content Collections: A Deep Dive Introducing… Astro Mart Astro Solstice Festival Astro 5.10 Astro 5.9 What's new in Astro - May 2025 Astro 5.8 What's new in Astro - April 2025 2025 Technical Steering Committee Starlight April Update Astro 5.7 Astro Agency Partner Program Astro 5.6 What's new in Astro - March 2025 Astro 5.5 What's new in Astro - February 2025 Astro 5.4 Starlight 0.32 Astro 5.3 What's new in Astro - January 2025 Astro 5.2 2024 year in review What's new in Astro - December 2024 Astro 5.0 Google IDX: Our Official Online Editor Partner What's new in Astro - November 2024 What's new in Astro - October 2024 Astro x Cloudinary SDK What's new in Astro - September 2024 Community Loaders for Astro Content Layer Astro x Hygraph: Content Loader Astro x Cloudinary: Content Loader Astro x Storyblok: Content Loader Content Layer: A Deep Dive Starlight 0.28 Astro 5.0 Beta Release The $100,000 Astro Ecosystem Fund Fall Update Goodbye Studio, Hello DB What's new in Astro - August 2024 Astro 4.15 Astro 4.14 Astro 4.13 What's new in Astro - July 2024 Astro 4.12: Server Islands Netlify: Our Official Deployment Partner What's new in Astro - June 2024 Astro 4.11 Astro Together 2024 Server Islands The Astro Content Layer Zero-JavaScript View Transitions Astro 4.10 Starlight turns one year old! What's new in Astro - May 2024 Astro 4.9 Astro 4.8 What's new in Astro - April 2024 Astro 4.7 Astro 4.6 What's new in Astro - March 2024 Migrating 500+ tests from Mocha to Node.js Astro DB: A Deep Dive The Astro Developer Portal Astro DB Astro 4.5
Astro 5.1
Matt Kane · 2024-12-19 · via The Astro Blog

Astro 5.1 is now available! Delivered just in time for the holidays, the first minor release of the Astro 5 era includes a new experimental sessions feature, improved caching for images, and extra tools for working with Astro Actions.

The gifts it comes bearing include:

  • Experimental: Sessions
  • Remote image caching
  • getActionPath helper

To upgrade an existing project, use the automated @astrojs/upgrade CLI tool. Alternatively, upgrade manually by running the upgrade command for your package manager:

# Recommended:

npx @astrojs/upgrade

# Manual:

npm install astro@latest

pnpm upgrade astro --latest

yarn upgrade astro --latest

Experimental: Sessions

If you’ve built apps with frameworks like Rails or Laravel, you’re probably familiar with sessions: a simple way to keep track of per-user data like login status, flash messages, or shopping carts as users navigate your site. Sessions let you securely store temporary data tied to a specific user – with no client-side storage required. Currently, you might store data in a cookie or local storage, but that can be insecure or cumbersome – or has limits on how much data you can store.

Sessions work by storing data on the server, and only sending a session ID as a cookie to the client. You can then get and set the session data in your Astro pages and components, API endpoints, Astro Actions, and middleware. The API and data are the same for each of them.

In Astro components and pages, you can access the session object as Astro.session:

---

export const prerender = false;

const cart = await Astro.session.get('cart');

---

<a href="/cart">🛒 {cart?.length ?? 0} items</a>

The same session data is available in your Astro Actions:

import { defineAction } from "astro:actions";

import { z } from "astro:schema";

export const server = {

addToCart: defineAction({

input: z.object({ productId: z.string() }),

handler: async (input, context) => {

const cart = await context.session.get("cart");

cart.push(input.productId);

await context.session.set("cart", cart);

return cart;

},

}),

};

Sessions work on pages that are rendered on-demand, or they pair perfectly with server islands, letting you sprinkle islands of personalized content in an otherwise static site.

---

import CartButton from '../components/CartButton.astro';

---

<CartButton server:defer />

Drivers

Astro sessions are powered by unstorage drivers, which are modules that Astro uses to store the session data. Unstorage supports dozens of providers, giving you a world of choice for storing user data.

When sessions become a stable feature, Astro’s official adapters will automatically configure a default driver. But during this experimental phase, you must configure a driver for your chosen adapter yourself. You can also use a cross-platform driver such as Upstash or Redis.

Usage

To try experimental sessions, add the experimental.sessions flag to your astro.config.mjs:

This example shows how to enable the filesystem driver, which works with the Node.js adapter:

{

adapter: node({ mode: 'standalone' }),

experimental: {

session: {

// Required: the name of the Unstorage driver

driver: "fs",

},

},

}

For more information see the sessions docs for this experimental flag . We’d also appreciate your feedback on the feature. For even more details, and to leave feedback and participate in the development of the feature, see the Sessions RFC.

Remote image caching

You already know and love the built-in <Image /> component to display optimized images with automatic resizing and optimization. While this component currently transforms both local and remote images, image caching between builds was limited to local images.

Now, Astro will cache remote images as well, reducing the need to re-download and re-transform images on every build. It uses conditional requests with If-Modified-Since or If-None-Match headers to determine whether the image is still fresh, and will use the cached version unless the source image has changed.

This is now enabled for all sites and will work with any host that supports conditional requests. See the new asset caching docs for details.

Special thanks to @oliverlynch, who contributed this feature!

getActionPath helper

Using Astro Actions is as simple as calling actions.like() or actions.addToCart(). But sometimes you need to know the URL of an action so you can make a fetch() request with custom headers, or use an API such as navigator.sendBeacon().

Astro 5.1 introduces a new helper function, getActionPath() to give you more flexibility when calling your action.

Need to authorize those likes? Call your like action passing the Authorization header and the keepalive option:

<script>

import { actions, getActionPath } from 'astro:actions'

await fetch(getActionPath(actions.like), {

method: 'POST',

headers: {

'Content-Type': 'application/json',

Authorization: 'Bearer YOUR_TOKEN'

},

body: JSON.stringify({ id: 'YOUR_ID' }),

keepalive: true

})

</script>

For more information, see the new getActionPath() documentation.

Bug fixes

We’ve had loads of great feedback since the Astro 5 release, and we’ve been working hard to fix the issues you’ve reported. See the changelog for all of the fixes since Astro 5.0.

Thanks to Florian Lefebvre (@florian-lefebvre), @oliverlynch, Sarah Rainsberger (@sarah11918), Yan (@yanthomasdev), Emanuele Stoppa (@ematipico), and everyone else who contributed to this release. Thanks also to everyone who’s been using Astro and sharing their feedback. We’re excited to see what you build with Astro 5.1!