wp-media / wp-rocket

Performance optimization plugin for WordPress
https://wp-rocket.me
GNU General Public License v2.0
687 stars 215 forks source link

Content loaded via Embeds should not be optimized #1632

Open Tabrisrp opened 5 years ago

Tabrisrp commented 5 years ago

When a post/page is loaded inside another one via the WP Embeds system, the content should not be cached/optimized, as that can cause display issues.

The content is loaded in an iframe, which can be optimized by the lazyload instead.

We can auto exclude the /(.*)/embed/ pattern to do that.

alfonso100 commented 3 weeks ago

We just had a case where the optimizations were applied to the embedded posts, causing a console error because of our DJE code.

The problem was the site doesn't use a trailing slash, so the embedded URL doesn't have a trailing slash after /embed:

https://site.com/2024/07/post-slug/embed#?secret=3jlHiimGWI%23?secret=F4WphFV28Y

and in our exclusion, we have the trailing slash:

https://github.com/wp-media/wp-rocket/blob/2cdeb587ebab0015a419c46d7213cd03f8ce6037/inc/functions/options.php#L233

Manually excluding (.*)/embed using the UI fixes the case.

We could consider making the trailing slash respect the current site settings

related slack thread (Internal): https://wp-media.slack.com/archives/C08N8J6VC/p1724082778400369?thread_ts=1723478860.717459&cid=C08N8J6VC