markus_blue_tomato Posted February 15, 2022 Share Posted February 15, 2022 Hi, I want to setup ProcessWire in Digital Ocean with a load balanced setup approach. Digital Ocean droplets can have a persistend file system called "block storage volume". The problem is, this block storage volume can't be shared between droplets which leads into issues with uploads and ProCache. I solved the uploads problem with the solution that the admin panel is only be used on the first droplets and assets (uploads) are synced with lsync to the other droplets und sessions are saved in redis. But I am struggling with this approach with ProCache. Requests to droplets 1 should be cached (and synced to dropled 2 and 3) but requests to droplets 2 and 3 shouldnt be cached since this would break my sync I guess... One idea I had is to set env variables on droplet 2 and 3 check the variable in _init.php and set https://processwire.com/api/ref/pro-cache/cache-on/ to false otherwise to true. Has anybody ideas to solve this? Link to comment Share on other sites More sharing options...
teppo Posted February 15, 2022 Share Posted February 15, 2022 In recent (4.x) versions of ProCache the docblock for ProCache::___allowCacheForPage suggest that it might be a good place to hook to prevent cache file from being created. I'd probably try hooking there and setting return value to false in case a specific env variable is defined (or not defined). Other than that... no obvious solutions here. 1 Link to comment Share on other sites More sharing options...
markus_blue_tomato Posted February 15, 2022 Author Share Posted February 15, 2022 9 hours ago, teppo said: In recent (4.x) versions of ProCache the docblock for ProCache::___allowCacheForPage suggest that it might be a good place to hook to prevent cache file from being created. I'd probably try hooking there and setting return value to false in case a specific env variable is defined (or not defined). Other than that... no obvious solutions here. Thanks I will look into this and if it works I will update this post ? 1 Link to comment Share on other sites More sharing options...
markus_blue_tomato Posted February 18, 2022 Author Share Posted February 18, 2022 On 2/15/2022 at 11:52 AM, teppo said: In recent (4.x) versions of ProCache the docblock for ProCache::___allowCacheForPage suggest that it might be a good place to hook to prevent cache file from being created. I'd probably try hooking there and setting return value to false in case a specific env variable is defined (or not defined). Other than that... no obvious solutions here. Thanks I will look into this and if it works I will update this post ? Update: Approach works ? $this->addHookAfter('ProCache::allowCacheForPage', function (HookEvent $event) { $event->return = (!empty(\DROPLET_HOSTNAME) && (\DROPLET_HOSTNAME === "my-droplet-production-01" || \DROPLET_HOSTNAME === "my-droplet-stage-01")) ? true : false; }); 2 Link to comment Share on other sites More sharing options...
Jonathan Lahijani Posted December 30, 2024 Share Posted December 30, 2024 On 2/15/2022 at 12:12 AM, markus_blue_tomato said: sessions are saved in redis @markus_blue_tomato Is there a reason you didn't use Session Handler Database? https://processwire.com/docs/security/sessions/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now