#Cache remote images

3 messages · Page 1 of 1 (latest)

proven thornBOT
#

Hi @rustic laurel. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, it is possible to adjust how Astro caches remote images.

Cache Directory

By default, Astro stores processed image assets (both local and remote) in ./node_modules/.astro. If you wish to change this location, you can use the cacheDir setting in your astro.config.mjs file [Asset Caching].

Remote Image Caching Logic

Astro manages remote images based on standard HTTP Caching rules. The caching behavior is primarily controlled by the remote server rather than Astro's configuration:

  • Cache-Control: Astro respects the Cache-Control header returned by the remote server. Images are cached if the header allows it and remain in the cache as long as they are considered "fresh" [Remote Images].
  • Revalidation: Starting in [email protected], Astro supports revalidation. This means if a cached image expires, Astro will check with the remote server (using If-Modified-Since or If-None-Match) to see if the image is still up-to-date. If the server indicates it is still fresh, Astro reuses the cached version instead of redownloading it [Revalidation].

To ensure your remote images are cached effectively, verify that the remote server hosting your images is sending appropriate Cache-Control, ETag, or Last-Modified headers [Revalidation].

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@rustic laurel Kapa.ai is still learning and improving, please let me know how I did by reacting below.