Delete Web Page Cache in CI4 |
I am using Full Page caching:
https://codeigniter.com/userguide4/general/caching.html It works perfectly. Now I need to delete a specific page cache. CI3 has a delete_cache() method to do that but I cannot find one for CI4: https://codeigniter.com/userguide3/general/caching.html Am I missing something? Ben.
The Cache class has a delete method.
You can get a reference to the Cache class anytime using PHP Code: $cache = Services::cache(); The delete method takes a string argument that is the cached item name. PHP Code: $cache->delete($key); The hard part, for which I have no answer, is how do you determine the value of $key.
It's based on a md5 hash of the full url of the page. This example are based on if you have cacheQueryString set to false and run in the Controller.
PHP Code: // Get the current page url automatically, in case you want to store it somewhere. You can of course specify the url manually if you like, you don't need to use createURIString. As long as the url matches, it will work. The md5 generated are the $key in the above post. |
Welcome Guest, Not a member yet? Register Sign In |