[FR]: Callable Cloud functions are using ephermal configuration and there's no way to use a URLCache of its requests #13172
Description
Description
Ephemeral Configuration: Callable cloud functions are designed to execute stateless logic triggered by client requests. However, the current setup lacks the capability to selectively cache certain requests while excluding others. This limitation arises because each function invocation starts fresh, without retaining previous state or configuration.
Need for Selective Caching: Selective caching is crucial in scenarios where callable cloud functions interact with external APIs or resources. It allows developers to optimize performance by caching responses that are static or less frequently updated, while ensuring that dynamic or sensitive data is not cached and potentially exposed.
Current Limitations: Due to the ephemeral nature of the configuration:
There's no mechanism to control which requests are cached and which are not within the function's execution context.
All requests are treated uniformly, leading to potential inefficiencies in caching strategies.
Developers are unable to implement fine-grained caching policies tailored to specific application requirements.
API Proposal
To address this issue, we propose enhancing callable cloud functions with:
Selective Caching Control: Introduce a mechanism to specify caching policies based on request parameters or headers.
Integration with Cache-Control Headers: Support Cache-Control headers to allow developers to indicate caching preferences (e.g., max-age, no-cache) for each request.
Programmatic Cache Management: Provide APIs or configuration options to enable developers to programmatically manage caching behavior based on application-specific logic, for example with a thread safe closure with a result of save it on cache or not.
Implementing these enhancements would:
Improve Performance: Enable efficient use of caching by selectively caching appropriate requests, thereby reducing response times and network latency.
Enhance Flexibility: Empower developers to implement caching strategies that align with their application's requirements and data sensitivity.
Maintain Security and Compliance: Ensure sensitive or dynamic data is not inadvertently cached, maintaining data privacy and compliance with regulations.
Firebase Product(s)
Functions
Activity