wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Partial Preload trying to access incorrect shop page urls (WooCommerce)

Open webtrainingwheels opened this issue 6 years ago • 26 comments

When you publish a product in WooCommerce or update it, Partial_Preload is trying to access some incorrect URLs for the page set as the Shop page in WooCommerce.

On every product publish/update, these 3 URLs 404: 404s

Steps to reproduce:

  • Activate WooCommerce
  • Go to WooCommerce > Settings > Products: make sure the Shop page has been set (it can be set to any page): https://jmp.sh/8midTHf
  • Make sure preload is active in WP Rocket
  • Update a product
  • Use whichever tool you like to log 404 errors (I used Redirection plugin)
  • Observe that the URLS indicated give a 404: https://jmp.sh/dGHBk7w

Tickets: https://secure.helpscout.net/conversation/986778716/127894?folderId=377611 https://secure.helpscout.net/conversation/983825572/127434?folderId=377611

webtrainingwheels avatar Oct 24 '19 17:10 webtrainingwheels

@Tabrisrp Is it a duplicate, or related to : https://github.com/wp-media/wp-rocket/issues/1904 ?

webtrainingwheels avatar Oct 24 '19 17:10 webtrainingwheels

Is the shop page the archive page for the Products CPT?

remyperona avatar Oct 24 '19 23:10 remyperona

@webtrainingwheels If you have a chance to remind you the problem, can you reply to @Tabrisrp question? 👆

GeekPress avatar May 15 '20 09:05 GeekPress

@Tabrisrp ummmm sorry for the delay! ;) Yes, the shop is the archive page for Products

webtrainingwheels avatar May 15 '20 19:05 webtrainingwheels

Related: https://secure.helpscout.net/conversation/1151176167/161778?folderId=2675957.

camilamadronero-zz avatar May 15 '20 19:05 camilamadronero-zz

@webtrainingwheels Thanks for the response. Will it be possible to update your original post with the Steps to reproduce section?

GeekPress avatar May 15 '20 21:05 GeekPress

@GeekPress done

webtrainingwheels avatar Jun 02 '20 20:06 webtrainingwheels

Another case here: https://secure.helpscout.net/conversation/1296584740/198620/

alfonso100 avatar Oct 29 '20 15:10 alfonso100

Similar case: https://secure.helpscout.net/conversation/1320995121/205970?folderId=377611 In this case it's the archive page for a different CPT, not the Shop one.

Similar to Alfonso's case above, Preload is trying to directly access: index-httpspage (???) index-https.html_gzip index-https.html

webtrainingwheels avatar Oct 29 '20 17:10 webtrainingwheels

Similar to Alfonso's case above, Preload is trying to directly access: index-httpspage (???)

When rocket_clean_post() runs we are gathering related posts to clean their cache. That's being done with rocket_get_purge_urls().

This seems like it could be coming from here: https://github.com/wp-media/wp-rocket/blob/e49355167e75f1d3cf51ee65c429b75f3e28682e/inc/common/purge.php#L74

vmanthos avatar Oct 30 '20 12:10 vmanthos

Same issue: https://secure.helpscout.net/conversation/1355362490/219272/

NataliaDrause avatar Dec 03 '20 08:12 NataliaDrause

This is happening because of what I mentioned in my previous comment on this thread.

We are adding the $filename here, which we shouldn't be doing: https://github.com/wp-media/wp-rocket/blob/e49355167e75f1d3cf51ee65c429b75f3e28682e/inc/common/purge.php#L74

Note: We should investigate if the resulting URL should include a trailing slash or not.

Slack Conversation: https://wp-media.slack.com/archives/C43T1AYMQ/p1610721622025900

Related ticket: https://secure.helpscout.net/conversation/1393456557/230505

vmanthos avatar Jan 15 '21 15:01 vmanthos

Related: https://secure.helpscout.net/conversation/1421855418/238401/

NataliaDrause avatar Feb 15 '21 10:02 NataliaDrause

https://secure.helpscout.net/conversation/1495106947/259280?folderId=377611

webtrainingwheels avatar Apr 27 '21 23:04 webtrainingwheels

Related: https://secure.helpscout.net/conversation/1561866652/276589/

NataliaDrause avatar Jul 05 '21 07:07 NataliaDrause

Related - https://secure.helpscout.net/conversation/1790422765/326752/

DahmaniAdame avatar Feb 24 '22 07:02 DahmaniAdame

Temporary solution: https://docs.wp-rocket.me/article/1506-remove-custom-post-urls-from-purge

webtrainingwheels avatar Mar 02 '22 16:03 webtrainingwheels

Related ticket: https://secure.helpscout.net/conversation/1824950567/333384/

This is for a custom post type created by the Divi Mega Pro plugin.

vmanthos avatar Apr 05 '22 06:04 vmanthos

https://secure.helpscout.net/conversation/1839999608/336206?folderId=377611

webtrainingwheels avatar Apr 07 '22 18:04 webtrainingwheels

Related: https://secure.helpscout.net/conversation/1861646403/339382?folderId=2135277

vmanthos avatar Apr 28 '22 07:04 vmanthos

Related https://secure.helpscout.net/conversation/1885893114/343229/

camilamadronero-zz avatar May 16 '22 20:05 camilamadronero-zz

Related https://secure.helpscout.net/conversation/1920201248/348460/

camilamadronero-zz avatar Jun 17 '22 14:06 camilamadronero-zz

https://secure.helpscout.net/conversation/1944925281/354956?folderId=377611

webtrainingwheels avatar Jul 11 '22 22:07 webtrainingwheels

https://secure.helpscout.net/conversation/1963318105/358804?folderId=3864740

NataliaDrause avatar Jul 31 '22 10:07 NataliaDrause

As an update for this specific case and the new Preload:

  1. Warning in the logs is not present
  2. We're clearing the cache of shop (archive for WooCommerce products) correctly
  3. We're not changing the status of shop in the database
  4. We're adding the unnecessary entries (shop/index-https.html shop/index-https.html_gzip shop-7/index-httpspage) to the database and setting their status to pending 20682

piotrbak avatar Sep 12 '22 12:09 piotrbak

Reproduce the problem

The problem was easy to reproduce.

Identify the root cause

The root cause of the problem is coming from the clearing cache logic. As we don't want it to clean recursively every files inside the shop folder, we have to precise files. However at the level of the preload we are saving urls given directly.

Scope a solution

A quick solution would be to remove index.html or index.html_gzip from url we add to preload.

For that we can create a new filter rocket_preload_format_url before adding the url to the database in create_or_update and create_or_nothing.

Then we will create a method format_preload_url on the Preload subscriber with the following logic:

public function format_preload_url( string $url ) {
 return preg_replace('/(index\.html)|(index\.html_gzip)$/', '', $url);
}

Finally we will hook that function to the filter rocket_preload_format_url.

Estimate the effort

Effort XS

CrochetFeve0251 avatar Sep 21 '22 06:09 CrochetFeve0251

Related: https://secure.helpscout.net/conversation/2032139861/373700?folderId=3864740

These URLs are being preloaded:

https://www.profesenapuros.com/tienda/index-httpspage/
https://www.profesenapuros.com/tienda/index-https.html_gzip/
https://www.profesenapuros.com/tienda/index-https.html/

NataliaDrause avatar Oct 10 '22 07:10 NataliaDrause

related: https://secure.helpscout.net/conversation/2004873613/367560?folderId=273766

alfonso100 avatar Nov 01 '22 14:11 alfonso100