With these settings, two otherwise identical requests with different In this case, the value of the Vary header is: vary: X-My-Custom-Header, x-fh-requested-host, accept-encoding, cookie, authorization For example: res.set('Vary', 'Accept-Encoding, X-My-Custom-Header') You can set the Vary header on your response. Other headers that you need to affect the cache. However, in some advanced use cases, you might have Most of the time, you don't need to worryĪbout the Vary header. Response (whether the cached content is valid or if the content should beįirebase Hosting automatically sets an appropriate Vary header on your The content of the request headers specified in the Vary headerĭetermines which request headers should be used to provide an appropriate.The browser and the CDN cache your content based on: You can learn more about the Cache-Control header on the However, other types of content canīe safely cached for hours, days, or even months. If a page changesĮvery few seconds, use a small time value. That you're comfortable with users receiving stale content. In theĮxample header, we're overriding the setting for max-age for the CDN onlyĪnd allowing the CDN to cache the content for ten minutes.įor max-age and s-maxage, set their values to the longest amount of time When the set timeĮxpires, the CDN must revalidate the content with the origin server. The CDN how many seconds that it can cache the content. S-maxage - Overrides the max-age directive for the CDN-caching only tells S-maxage below for specific controls for CDN caching). In the example header, we'reĪllowing the browser and the CDN to cache the content for five minutes (see Revalidate the content with the origin server. ![]() When the set time expires, the browser and the CDN must Max-age - Tells the browser and the CDN how many seconds that they can cache Requesting user is allowed to cache the content. This means that if youĭon't explicitly set Cache-Control to public, only the browser of the Note: By default, Cache-Control is set to private. The intermediate servers (meaning the CDN for Firebase Hosting) can cache In this example header, the directives do three things: You set Cache-Control like so: res.set('Cache-Control', 'public, max-age=300, s-maxage=600') The browser and the CDN how long your content can be cached. By configuring this header, you can communicate both to The main tool that you use to manage cache for dynamic content is theĬache-Control header. Learn more about caching behavior in Google's Optimizing function execution and services in the Served from the CDN rather than via a triggered function. You can also potentially reduce function execution costs because the content is Your app by caching the generated content for at least a short period of time. ForĮxample, if a function generates new content only periodically, you can speed up You can, though, configure caching behavior for dynamic content. Handled by backend code do not cache on the CDN by default. However, because Cloud Functions and Cloud Run services generateĬontent dynamically, the content for a given URL can vary based on such thingsĪs user input or the user's identity. ![]() Redeploy your site's content, Firebase Hosting automatically clears all yourĬached static content across the CDN until the next request. Firebase Hosting uses a powerful global CDN to make your site as fast asĪny requested static content is automatically cached on the CDN.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |