Caching issue in X-cart 5 – Cache losing automatically after 1 hour | Lucid Softech

Caching issue in X-cart 5 – Cache losing automatically after 1 hour

By Lucid Softech IT Solutions | x-cart customization, x-cart development,  04 Jul 2016


We are currently working on a jewelry site developed in X-cart 5.2.13. We have done all the work properly. The site is made live and things were working fine. We worked on improving the speed of the website. We implemented memcache to cache the site so that speed is good. We ran test through common speed tool like gtmetrix, pingdom and the google speed was super quick something under 2 sec for the products having more than 45 product groups on 1 page which was bit heavy. But we managed to get there.

Caching issue in X-cart 5 – Cache losing automatically after 1 hour

Problem We Faced

Suddenly we noticed a strange issue on the site that exactly after 1 hr the site was becoming slow and going down to the load time from 2secs to 10secs. Just to let you know that we set the memcache to 0 so that it never expires and the syntax for the same was also correct. And if the memcache would have not worked then this would have not been able to work for even 1 hour, but it kept losing cache after 1 hour.

Since cache was not getting held, we thought that this is issue with memcache and decided to use nginx in place of memcache but that also did not solved our problem. Just to let you know here that nginx is also a caching system which helps in speeding up the website. So when nginx didn’t work we again came back to memcache as the issue with memcache was ruled out.

The path for the file in which we did the change for memcache settings:
Below is the screenshot which shows the memcache setting we did in the file


So there was something else which was causing the problem and we had no clue.

After all our efforts we contacted hosting company to check server settings if it is all fine? They responded that all the optimization at server level was OK and memcache was also working fine. We did all the cache setting in the X-cart backend which were given as suggestion for store optimization but with no success. Even those settings were not of help in explaining why the cache was kept on losing after 1 hour. Below is the store backend cache setting we did which was all good.


Then we decided to contact X-cart for this issue. They said they will look into the issue and will come back in few days and in the meanwhile we decided to upgrade the site to latest version assuming that some improvements may have come which will improve the speed but we were 99% sure that this is not related to version upgrade but we had no option.

Success We Achieved

While doing upgrade my x-cart developer noticed a file where there was a function which is defining the time for holding cache for filter and module and that was set to 3600secs i.e. 1hr. We changed to 0 to set it to never expire, and then again checked and this time you guessed it right the cache was maintained for more than 1 hr. We checked for 2-3 days and it was there. We made changes to following files

Below is the code we changed in all the 3 files. Earlier it was set to 3600secs which we changed to 0 to hold the cache forever.


So finally we concluded that we have done all the setting right in X-cart. But even after doing settings from the backend it was getting override by the function built to hold cache to only 1 hour by default.
So if you ever get into this issue don’t forget to check these files and functions.

Contact Us Now For No Obligation Quote

Copyright © 2024, All rights reserved.