page-cache icon indicating copy to clipboard operation
page-cache copied to clipboard

Document suggestion for cache invalidation

Open denudge opened this issue 3 years ago • 3 comments

Since the PHP stack is out of reach, I don't see how cache invalidation works. For example, to renew the generated start page of a content driven site every 10 minutes. Please provide a suggestion how to handle that.

Thanks in advance.

denudge avatar Oct 17 '20 12:10 denudge

I don't see that either, but you could schedule the artisan command for the specific slug.

One could also use this to create an observer that clears the specific cache entry when saving a model. I have not used his package for now, but the availability of this command suggests that there also is a call that can be made without using the scheduling functionality. It would be nice if that would be documented, though.

jberculo avatar Nov 10 '20 08:11 jberculo

I added the something like this to an observer, and it works:

$cache = app()->make(Cache::class);
$cache->clear($slug);
$cache->forget($slug);

jberculo avatar Nov 12 '20 17:11 jberculo

I was thinking about how to do this as well. However, in my case we have more than 1 web server in a serverless context, so cache invalidation needs to be propagated across all of them.

deevus avatar Apr 07 '21 01:04 deevus