0

I've got a client who has a very odd problem that appeared out of virtually nowhere. It seems that their site is caching absolutely everything that could possibly be cached. I've turned Magento cache off and talked to the hosting company, and there is apparently no caching set up for the site right now.

Right now, if you place an item in your cart for the first time, everything seems to work fine. If you attempt to remove an object, the cart will appear to still have the item in it. The only way to get the cart to update is to refresh the browser 2 or 3 times. If you attempt to put another item into the cart, you must refresh the browser to get it to appear in the cart.

If you log into the admin panel and try to clear cache, reindex, turn on path hints, or really do anything that would show that you updated anything on the back end, you have to refresh the browser to get it to show up. So, for instance, say you tell the site to reindex the search engine. The site will act like it's reindexing, then do the usual auto-refresh, but the search engine will still appear to need indexing (ie it will be red) until you hit F5 to reload. Then the search engine index warning will turn green.

I'm at a loss at this point for why the entire site is caching like this. I have a dev site that is roughly identical to this live site and it's not having any of these problems. The only difference is that the dev site is hosted with a different company entirely.

The only StackExchange post I've seen that resembles this issue is here, but the reported fix didn't work for me. Any help is much appreciated.

2 Answers 2

1

Sounds like local browser caching to me rather than server side. Try sending the following headers for each page to disable browser caching.

<?php
header('Cache-Control: max-age=0, no-cache, must-revalidate');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Pragma: no-cache');
5
  • I threw that code snippet first thing into the head.phtml for my template, but it still doesn't seem to be working for me. Maybe I'm confused about where to put this? Commented Feb 1, 2016 at 15:32
  • 1
    Use something like firebug to look at the response headers - if you see the above you should be ok. Commented Feb 1, 2016 at 16:11
  • The response headers are definitely different between my working dev site and the live site. That may be a good place to start looking. I must admit, I know very little about headers as they pertain to servers. Commented Feb 1, 2016 at 22:07
  • 1
    For the purposes of your problem, as long as you are seeing the above headers in the server response, then the browser shouldn't do any local caching of that HTML content. Commented Feb 2, 2016 at 9:56
  • Well, the response headers on the broken site are saying Cache-Control: max-age=10, while the Cache-Control on the working dev site says no-cache. So, yeah, I'm guessing there's a server config issue on the broken site somewhere down the line. Commented Feb 2, 2016 at 15:01
0

So, we finally figured out the issue. The site was being cached by a 3rd party security application that sat between the DNS and the server. We had no idea that this caching had been turned on, and the hosting company wasn't seeing any caching on their end, so it was driving us crazy.

So anyone who runs into this problem in the future, make sure to check if there are any 3rd party security apps running separate from your host.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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