How to stop codeigniter 4 from cashing webpage

1.3k views Asked by At

Please I want to totally stop cache in my codeigniter 4 project. It caches some of my webpage without instructing it to. I have use the below code but did not achieve my aim:

  $cache = \Config\Services::cache();

           $cache->clean();

It is frustrating when the site caches another user's account and enabling the entire members to see someone's account. I don't know if am the only one experiencing this or global issue... PLEASE I NEED HELP.

1

There are 1 answers

11
marcogmonteiro On

If you open your app/Config/cache.php file and didn't change anything there then your cache handler should still be "file". If that is the case and you didn't load your cache service anywhere in your app then codeigniter will not cache anything.

Actually, if you open your writable/cache folder that should be empty too.

Although if you are in fact caching something in your app and want to remove the cache data that should be the correct way of doing it.

This method will ‘clean’ the entire cache. If the deletion of the cache files fails, the method will return FALSE.

If you're not sure on what cache is being saved or how, you can also check that by using the cache_info method.

cache_info()
Returns:    Information on the entire cache database
Return type:    mixed

This method will return information on the entire cache.

Example:

var_dump($cache->getCacheInfo());

If there's actually no cache being used you might want to look into your sessions, your problem might come from there.