wp-media / wp-rocket

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

Distinguishing real Internet Explorer users from Outlook users. #6121

Open rosamillan opened 11 months ago

rosamillan commented 11 months ago

Is your feature request related to a problem? Please describe. Client Says: Every time we send out a newsletter that drives traffic to our site, the server is overloaded. It seems like a really high number of URLs have the ?nowprocket query parameter which bypasses the page cache. MS Outlook is detected as IE by WP Rocket.

Describe the solution you'd like Add in WP Rocket a way to distinguish MS Outlook from IE.

Describe alternatives you've considered Add MS Outlook compatibility Add an option that allows you to disable the redirection to the uncached version - if it's what the user wants.

Additional context Ticket: https://secure.helpscout.net/conversation/2341813954/439296?folderId=7406897 Slack thread: https://wp-media.slack.com/archives/C08N8J6VC/p1693244729958839

reggieofarrell commented 11 months ago

Hi @rosamillan. I'm the developer on the site where this user agent check is causing us problems. There is a pretty quick/simple fix for this if a filter could just be added to allow disabling this check. I've already tested it on my local copy of the site...

wp-content/plugins/wp-rocket/inc/Engine/Optimization/DelayJS/Subscriber.php

if ( !apply_filters( 'rocket_disable_ie11_check', false ) ) {
  $replaced_html = preg_replace( $pattern, '$0<script>' . $this->html->get_ie_fallback() . '</script>', $replaced_html, 1 );
}

Then if someone wants to disable this check all they need to do is add this filter to their theme...

add_filter('rocket_disable_ie11_check', '__return_true');
reggieofarrell commented 4 months ago

Hi @rosamillan @piotrbak . Any idea when this might make it into the codebase? It's been quite a while. Can I just make a PR myself? We have to keep adding this code to the plugin every time we update it which is not ideal.

piotrbak commented 4 months ago

Hello @reggieofarrell I have concerns if our Delay JS will work on the native browser there. Have you considered disabling it programatically when the specific User Agent is used? https://docs.wp-rocket.me/article/1561-programmatically-toggle-wp-rocket-options-under-specific-conditions

reggieofarrell commented 3 months ago

@piotrbak By "native browser" I assume you mean the embedded browser in iOS/Android apps? Could you go into more detail about why you're concerned about this?

Meanwhile, I'll look into your suggestion. Thanks.

piotrbak commented 3 months ago

@reggieofarrell This check here is present to make sure that JavaScript works correctly on specific browsers (MSIE|Internet Explorer|/Trident\/7..*?rv:11/) when Delay JS is enabled.

If you remove this check without disabling Delay JS, JavaScript might not be executed correctly on those browsers, possibly including Outlook.