You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an issue on my side I can't wrap my head around.
I used the middleware on the following route
Route::get('/post/{slug}', [BlogController::class, 'showPost'])->middleware('cacheResponse')->name('blog.showpost');
It works well, the response is cached when I hit http://mywebsite.com/post/example
Then, when I want to forget the cache for a specific URL, I'll call this function
public function forgetCache($slug): JsonResponse
{
ResponseCache::selectCachedItems()->forUrls('/post/'.$slug)->forget();
....
}
But this code does not forget the URL with the specified slug ("example" as per my previous example) ... (it works well with ResponseCache::clear(); but I don't want to wipe everything)
The slug is obviously the same. I'm sure I'm missing something obvious but I don't understand what at this moment.
Any help would be appreciated ! Thanks a lot !
EDIT : it WORKS when I return an empty string in useCacheNameSuffix but I thought selectCachedItems was the way to get around the suffix ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I have an issue on my side I can't wrap my head around.
I used the middleware on the following route
Route::get('/post/{slug}', [BlogController::class, 'showPost'])->middleware('cacheResponse')->name('blog.showpost');
It works well, the response is cached when I hit http://mywebsite.com/post/example
Then, when I want to forget the cache for a specific URL, I'll call this function
But this code does not forget the URL with the specified slug ("example" as per my previous example) ... (it works well with ResponseCache::clear(); but I don't want to wipe everything)
The slug is obviously the same. I'm sure I'm missing something obvious but I don't understand what at this moment.
Any help would be appreciated ! Thanks a lot !
EDIT : it WORKS when I return an empty string in useCacheNameSuffix but I thought selectCachedItems was the way to get around the suffix ?
Beta Was this translation helpful? Give feedback.
All reactions