Code Monkey home page Code Monkey logo

Comments (4)

zeopix avatar zeopix commented on July 24, 2024

Thanks for creating this ticket @piotrbak .

You can reproduce this issue with some simple steps:

  • Create a clean WP site.
  • Add WPML Plugin, register it, add few languages.
  • Install WP Rocket, go to Settings > Wp Rocket > Cache > "Enable cache for logged-in wordpress users".
  • In the following request, the problem already occurs.
  • It can also occur when applying a translation, and many other cinrcumstances (whatever hook ends up calling rocket_clean_domain in inc/functions/files.php).

The problem is because in this method, the cache is cleared for each $url, and $url is retrieved using the function get_rocket_i18n_uri or get_rocket_i18n_home_url, which retrieves one URL per language.
This seems fine because some hooks are fired per URL, this logic seems to be correct, but later, a hook after_rocket_clean_domain is fired per URL, which is bound to clear_full_cache hook.

This later one, will do the same query on every step, so we propose to extract this hook from the foreach ( $urls as $url ) {

(Se how we tweaked this function in this gist)

An update query like this on every row of the wpv_table, repeated n times (where n=number of languages) locks this table and saturates mysql in large sites causing a significant performance impact.

from wp-rocket.

Tabrisrp avatar Tabrisrp commented on July 24, 2024

Scope a solution ✅

We can add a new filter outside of the loop rocket_after_clean_domain, and update the hook used in the preload subscriber (Could be also good to investigate other usages of the after_rocket_clean_domain filter to see if they could be changed and reduce the number of calls to the hooked methods).

Estimate the effort ✅

Effort [S]

from wp-rocket.

CrochetFeve0251 avatar CrochetFeve0251 commented on July 24, 2024

Seems good to me

from wp-rocket.

wordpressfan avatar wordpressfan commented on July 24, 2024

Small discussion: https://wp-media.slack.com/archives/CUT7FLHF1/p1698656302149819

We need to create a new action not filter exactly here:

from wp-rocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.