Caching Data
Browser caching in Senza
Overview
Senza enhances caching opportunities by utilizing shared browsers on shared machines. This document outlines the best practices and considerations for implementing browser caching in the Senza environment.
Browser Cache Implementation
Standard Chrome Implementation
- Senza's browser cache functionality is based on the standard implementation of Chrome. This means that most caching behaviors and optimizations present in Chrome are also applicable in Senza.
HTTP Cache Usage
- Developers are strongly advised to utilize HTTP caching, especially for static files (resources, Images, js, css etc...). This can be achieved by sending the
Cache-Control
header with appropriate expiry times in HTTP responses. - As in all environments, A cache hit, is not guaranteed to be 100%. It depends on whether the UI-streamer node currently being used contains the cached content.
Considerations for Shared Browser Environment
Cache Sharing Across Multiple Users
- In Senza, multiple users may access the same browser instance (though not simultaneously). This shared environment necessitates specific considerations:
Private Caches
- For caches specific to private APIs or user-sensitive data, it's essential to include an appropriate
Vary
header. This ensures that cached responses are appropriately varied based on the requesting user's characteristics or not cached at all. - Adherence to standard caching protocols is crucial, especially in handling private or sensitive data in a shared browser context.
Support for Standard Cache API
- Senza supports the Standard Caches API https://developer.mozilla.org/en-US/docs/Web/API/Cache. This allows developers to manage the caching of requests and their responses, providing more control over what gets cached and how it is retrieved.
Best Practices
- Utilize the
Cache-Control
header for effective cache management. - Be mindful of the shared nature of the browser environment in Senza when caching private or sensitive data.
- Regularly review and adhere to standard caching protocols to ensure efficient and secure caching strategies.
Updated 7 months ago