Ad

Load A The Page Itself When 410 Error Is Send Intentionally For SEO Purposes

I have got a website with lots of products which can be bought by clients.

I have implemented an adding to cart button which adds the product to a Session variable after clicking on it. A part from this, there is a cart icon on the header of the page which has a number that increases depending on the quantity of products that there are on the cart with a jquery function: $("#topcart").load(location.href+" #topcarrito");. It loads only the div that contains the length of the array which contains the products cart session variable.

All this stuff has always worked perfectly since my SEO coworker wanted me to apply a 410 error-code to some products for SEO purposes, just to have less products indexed as they were redundant (non-rich descriptions and so). The way I did it was by adding header('HTTP/1.1 410 Gone'); to them.

The problem is that at this time, when I try to add a product that has a 410 error set up to the cart, as the web browser detects the error, it does not load the div with the updated quantity of products in the cart. Instead, the console shows up the 410 erorr. However, if I reload the page by ckicking F5 the number of products in the cart loads correctly, so the product got added to the cart.

Is there any way I can do to load that div even when the browser detects the 410 error?

Ad

Answer

Just in case someone has this problem as well, I've finally found a way to solve it.

What I did is to create a new php file which gets the count of the session array and echo it, get it through an AJAX call and then modify the div with a simple $("#topcarrito").text(value) so there is no need to load the page that gives the 410 error.

Ad
source: stackoverflow.com
Ad