Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Override defaults in cache.php

Started by Muut Archive 10 years ago · 3 replies · 337 views
10 years ago

Is there a way to override this in cache.php:

protected static $standard_remove = [
'cache://twig/',
'cache://doctrine/',
'cache://compiled/',
'cache://validated-',
'cache://images',
'asset://',
];

PHP
protected static $all_remove = [
    'cache://',
    'cache://images',
    'asset://'
];

protected static $assets_remove = [
    'asset://'
]; 

protected static $images_remove = [
    'cache://images'
];

protected static $cache_remove = [
    'cache://'
];

In a plugin? I want to remove all instances of 'cache://images',

10 years ago

It is an interesting thought, I would presume one of the event hooks could do it, though I am not familiar with the process. I would be interested in your results though, disabling the caching of images could be useful where this is done manually or outside of Grav.

10 years ago

I'm not trying to prevent the caching of images, but to prevent the clearing of cached images on every cache-clear. My image cache is +1GB so I don't want to recreate all images on every cache-clear. Anyway, I extended the Cache class in a plugin, and set the variables in my own class using parent::$standard_remove = $caches;
and it works. The only thing I'm still wondering is whether cli cache-clear commands reacts in the same manner to the events, as would a normal page request.

10 years ago

Currently there is no way to override these. However, improvements an be added to the core version by providing a Pull Request if the are generic enough to be of use for everyone.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1356 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2954 9 years ago
Archive · by Muut Archive, 9 years ago
3 1120 9 years ago