Feature Request: Customizable Data Caching in Inertia.js #1720
joydeep-bhowmik
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
Inertia.js currently provides a convenient way to build server-driven spa applications, but there is room for improvement in terms of controlling data caching for specific requests. The ability to pass caching instructions from the server to the client-side adapter would be a valuable addition.
Requested Feature:
Cache Instruction Property: Introduce a new property, let's call it
cache
, that can be added to the data returned viaInertia::render
in Laravel. This property would allow developers to specify caching behavior for specific requests.Custom Cache Duration: Developers should be able to set a custom cache duration for each request, indicating how long the client-side adapter should cache the data.
Control on the Client-side Adapter: The Inertia.js client-side adapter should respect the
cache
property and store the data in local storage or a similar mechanism for the specified duration.Optional Cache Busting: Include an option to manually invalidate or refresh the cached data when needed, such as after an update or specific user actions.
Use Case:
For example, when rendering a list of blog posts, a developer could set the
cache
property to instruct the client-side adapter to cache the data for a longer duration (e.g., 5 minutes) as blog posts typically don't change frequently. This would reduce unnecessary server requests and improve the application's performance.Benefits:
This feature would enhance Inertia.js as a tool for building highly performant and efficient server-driven web applications. Thank you for considering this feature request.
Beta Was this translation helpful? Give feedback.
All reactions