The PowerGrid caching feature is not working #1984
Yash-Mahadevwala
started this conversation in
BUG
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.
-
Livewire PowerGrid version
v5 & v6
Livewire version
v3.5
Laravel version
v3.5
Which PHP version are you using?
PHP 8.2
Which Theme are you using?
Bootstrap 5
Have you published the resource files and customized them? (php artisan vendor:publish)
Yes
What is the problem?
Bug Report + Feature Request: PowerGrid Caching Not Working as Expected
Description:
The PowerGrid caching feature is not functioning as expected. Currently, when caching is enabled, no data is served from cache — every request still triggers fresh database queries.
Additionally, we need a feature enhancement: caching only the first page of records (e.g., 10 records). Other pages, filters, or sorts should always query the database directly. This would help improve performance while keeping dynamic functionality intact.
Steps to Reproduce (Bug):
Enable caching in PowerGrid configuration.
Load a listing table (first request works as expected).
Reload the same table without making changes.
Observe that the database query executes again instead of using cached results.
Expected Behavior (Bug):
Subsequent requests should serve cached data until the cache expires or is invalidated.
Actual Behavior (Bug):
The database query runs on every request, even if no changes are made.
Feature Request – Partial Caching:
Cache only the first page (default 10 records).
For subsequent pages, filters, and sorts → always fetch fresh data from DB.
This helps with performance on initial load while ensuring filters and pagination remain accurate.
Impact:
Bug: Caching has no effect, increasing DB load.
Feature: Ability to cache only first-page results would significantly reduce load on high-traffic tables while keeping UX smooth.
Code snippets
public function datasource()
{
$baseQuery = Dish::with(['category', 'kitchen'])
->when(
$this->categoryId,
fn ($builder) => $builder->whereHas(
'category',
fn ($builder) => $builder->where('category_id', $this->categoryId)
)
);
}
How do you expect it to work?
How I Expect It to Work
Bug fix expectation:
When caching is enabled in PowerGrid, subsequent requests for the same table and parameters should serve data directly from cache (until the cache expires or is invalidated).
Example: If I open the first page, it should load from DB once, then reloads should come from cache without hitting DB again.
Feature expectation (first-page-only caching):
The first page (default 10 rows) should be cached and served from cache until it expires.
Other pages (2, 3, …) should always run live DB queries.
Filters and sorting should bypass cache and always query fresh results.
Expected benefit:
Faster initial load time for large tables.
Reduced DB load on high-traffic pages.
Dynamic data (filters, sorts, pagination) still remains accurate.
Please confirm (incomplete submissions will not be addressed)
Beta Was this translation helpful? Give feedback.
All reactions