Flush / clear cache where no user has ADMIN role

Silverstripe Version: 4.*

I have a specific problem with clearing cache.
The application runs behind a load balancer where the users with admin roles are only on one server.

sake dev/build "flush=1"

works on “admin” server but not on two other servers. Build works ok. Flush doesn’t work. And there are no errors. Sysops suggested that we put all cache in a specific folder which he could delete directly.
What would you suggest we do?

The ideal would be to share your cache across instances (and make sure you’ve done a proper audit of the data which is being cached to ensure there’s no data leaks).

How are you currently handling session storage across the servers?

You could add a shared NFS mount for the servers, you could use something like redis or memcache as a common cache, there are a couple of modules around which make that fairly easy.

A lot depends on the technology you have available in your stack really.

The docs on cache adapters are here: https://docs.silverstripe.org/en/5/developer_guides/performance/caching/#adapters

They may provide some ideas too.

1 Like

My team have found that using the the default cache system over NFS has race conditions and a lack of locking, which lead to crashes from multiple processes writing the same cache files.

Our solution has been to offload as much caching as possible to redis. There are, however, some parts of Silverstripe that are hardwired to use the filesystem for caching. For those bits, we allow each PHP server to have its own local cache. We use a custom Deployer recipe to purge those on deployment.

1 Like

We found out what the problem was. Sysops was clearing cache on one server and relied on sync to clear the other two… Anyway once he ran sake dev/build “flush” on each server it cleared all caches and now it works :slight_smile:

1 Like