Hossj Hossj - 1 year ago 82
PHP Question

Delete cache on a dynamic page in CodeIgniter

I have reviewed the documentation of CI regarding caching a full page here:

I understand that I can cache a controller/function using the below; anywhere inside that function:


However my problem is that for example we have a page:


as you can see the

  • controller->article

  • function->specific

  • slug->this-is-a-slug

When I cache the function inside itself, the system automatically detects that slug and creates a new cache for each slug uniquely.

However when I want to delete the cache for that specific slug I do not know how I can do it outside the function itself:


How can specific that I need only the cache for this specific slug to be deleted?

Answer Source

You can do it wherever you wish, as long as you know the URI. The string in the delete_cache is the URI.


Caching can be enabled on a per-page basis, and you can set the length of time that a page should remain cached before being refreshed.