7

I have integrated a cache warmer module. Using cronjob it runs and creates cache for all the pages, and it's working properly.

I have multiple servers (Let's say 2 servers), until now there is no need to schedule cronjobs for all servers, I used to schedule cronjobs only on first server.

Since cache used local storage to save cached data, if I schedule cronjob on one server, then cache warmer wont work on other server.

Now my question is, how can I create cache for both servers while cron is scheduled on first server

| improve this question | | | | |
  • how often do you run the cache warmer? I am not sure what the default expiry time for cached varnished pages is and how often to warm the cache. – paj Feb 10 at 17:37
  • every 24 hours is best time for cache, in addition I have created a command to warm cache. So when I flush cache I can also warm it with command line – Shoaib Munir Feb 11 at 4:34
  • so default ttl for varnish pages is 24 hours? – paj Feb 11 at 15:43
  • Sorry, don't know exactly – Shoaib Munir Feb 11 at 16:34
5

In local cache environment it is impossible to create cache for both servers while executing cron on one server.

There is only one option left, make cache centralize.

To do this you need to use either Varnish or Redis. I have read multiple articles and all of them saying that Varnish is better approach. But I have used AWS Elasticache Redis on my server as it is more cheap and I have less knowledge of Varnish right now :D

To implement redis I have executed this command on shell (Putty)

php bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=127.0.0.1 --page-cache-redis-db=1

I have used my server details in above command (Obviously)

And now I have centralized storage of Full Page Cache, and I have scheduled cronjob on one server and it is working fine for both servers.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.