Litespeed Caching Magento 404s?

#1
Good afternoon,

I'm the owner of www.redcandy.co.uk, and our server company (United Hosting) installed Litespeed on our server maybe a year or so ago.

I'm extremely happy with the results, other than a strange quirk where Litespeed is sometimes caching 404 pages generated in Magento.

On occasion when we create a new product page or edit an existing page that page will immediately 404 upon save. Without Litespeed enabled the 404 would disappear the next time the page was reloaded. With Litespeed enabled the 404 is cached and retained until the cache is purged.

I've spent soooooo much time & money with my web developers trying to crack the 404 issue but haven't had any joy. I've involved our hosts multiple times, but they've not been able to assist too much as the issue appears to be sat deep in our bespoke Magento build.

I'm giving up on the Magento side for the meantime, so was wondering if there was a way to prevent Litespeed from ever caching 404s? This would make me very happy indeed!!!

I have to now state that I'm not a coder, and also don't understand server configurations, so my apologies if the description of the issue sounds a bit basic!!

Any pointers at all would be greatly appreciated! :)

Kind regards,

Andy
 
Last edited by a moderator:

Lauren

LiteSpeed Staff
Staff member
#2
The stuff on your site is so cute and lovely. :)
It's Magento 1 site. I think the problem is during save, and someone access the url, Magento is not ready yet in its index to serve the page, and shows 404.
One simple solution is:
After you save the product, you can visit the url directly, and see if it's 404. If it is, on the product edit page, there's a litemage purge button, you can choose purge this product only, or purge product and related categories. then you can double check from the brower and see if the url is properly displayed.
You can also do from the cache management screen, purge by ID, select type "Product", and put product ID in the ID input, to purge that product page.

This way the real 404 page is still cached. As you do want to cache 404 pages in general.
Let me know if this solution will work for you or not.

Lauren
 
#3
Good morning Lauren,

Thanks so much for saying! We do have a lot of fun sourcing these products! :D

Thanks also for your detailed response - it is greatly appreciated. Please see below for my comments:

It's Magento 1 site. I think the problem is during save, and someone access the url, Magento is not ready yet in its index to serve the page, and shows 404.
My web dev team have mentioned this Magento issue previously, so we now don't view new products in the front end for 5+ minutes. This still might be partly responsible, but the 404ing also affects existing products. If we edit the description of an existing product (NOT touching the URL) and then save it, it sometimes 404s. We have also stumbled seemingly random existing products which we HAVEN'T edited for months return a 404 which has been cached. It's very odd behaviour...

After you save the product, you can visit the url directly, and see if it's 404. If it is, on the product edit page, there's a litemage purge button, you can choose purge this product only, or purge product and related categories. then you can double check from the brower and see if the url is properly displayed.
You can also do from the cache management screen, purge by ID, select type "Product", and put product ID in the ID input, to purge that product page.

This way the real 404 page is still cached. As you do want to cache 404 pages in general.
Thanks for the solution. At present I append affected URLs with /?LITEMAGE_CTRL=PURGE to purge them individually. However, as we have a few thousand products and stumble across randomly affected pages, it stands to reason that we were only spotting a relatively small percentage of affected products... Everybody in my team has to remember to check each product after creating or re-saving it - and sometimes somebody will forget to do this.

Is there any way (even if it is a bit hacky!?) to prevent ANY 404 page from being cached by Litespeed? At this point I can't think of anything else we can look at..!

Thanks again for your assistance.

Kind regards

Andy
 
Last edited by a moderator:

Lauren

LiteSpeed Staff
Staff member
#5
Andy,

The Purge product button is on the product edit page next to save. so when you save it, you can just click "Purge product" button on the same page.
It's also possible to update code to not cache 404 page if you want to do that way. But this will come as a cost for real 404 pages, it will cost server resources to not cache.

Lauren
 
#6
Good morning Lauren,

Due to the sheer number of pages we have the above solution isn't workable, as we would have to continuously check each individual page for a 404, and then fix it manually.

For this reason I have added the following headers to the PHP code for 404 pages:

<?php
header('X-LiteSpeed-Cache-Control: no-cache');

?>

However, this also is not working, as you can see below:

https://www.redcandy.co.uk/cubic-skull-printed-mirror

Can you please let me know what I need to try next?

Many thanks

Andy
 
Top