• Resolved xu wu

    (@wuxu)


    Hello,

    The first question:

    When a page with the extension ?trp-edit-translation=preview is accessed, Both logged in and unlogged in users. hundreds of /wp-content/plugins/translatepress-multilingual/includes/trp-ajax.php requests are launched, And if you don’t modify the page, it will load in a loop forever.

    final resulting in triggering of the nginx firewall CC rule.

    Why is it that when using URLs ending in ?trp-edit-translation=preview can’t it trigger a 403 warning message for unlogged users like /?trp-edit-translation=true?

    Why does it keep looping loading trp-ajax.php even when a logged in user visits the URL ending ?trp-edit-translation=preview?

    ===============================================

    The second question:

    When I am logged in and am an administrator, if I add a true string to a non-existent URL,

    For example: /HHFGKJF11222222/?trp-edit-translation=true

    the page will open 404 page, but the page will keep getting /wp-admin/admin-ajax.php, which is also hundreds of times, and it will not stop until the nginx firewall CC rule is triggered.

    Looking forward to your reply, thanks!

Viewing 1 replies (of 1 total)
  • Plugin Support Alex

    (@alexcozmoslabs)

    Hi,

    1. The ?trp-edit-translation=preview parameter is intended for translation previews, and during this mode, TranslatePress relies on trp-ajax.php to fetch translations dynamically.
    However, in some cases, a misconfiguration, caching, or conflicts with security rules (such as Nginx firewall rules) may cause repeated requests. If TranslatePress does not receive the expected response, it may retry indefinitely, leading to excessive AJAX calls.
    The trp-edit-translation=true parameter is restricted to administrators, and if an unlogged user tries to access it, a 403 response is returned.
    The trp-edit-translation=preview parameter, however, is designed to allow previewing, and currently does not enforce the same level of access control.

    2. When accessing a non-existent URL with ?trp-edit-translation=true, TranslatePress still attempts to process translations and since the page is a 404, there are no translation strings to fetch, potentially causing a loop of retry requests.

    ———————-

    TranslatePress utilizes trp-ajax.php to dynamically translate content loaded via JavaScript. However, in some cases, especially with content that frequently updates or is loaded dynamically, this can result in numerous AJAX requests, impacting server performance.

    Potential Solutions:

    A. Exclude Specific Content from Dynamic Translation:
    If certain elements on your page are causing repeated AJAX requests due to dynamic content, you can exclude these elements from dynamic translation. This prevents TranslatePress from continuously detecting and translating content that changes frequently.
    *Identify the Problematic Elements: Use your browser’s developer tools to pinpoint which elements are causing excessive AJAX requests.
    *Add Exclusions in TranslatePress:
    a. Navigate to Settings > TranslatePress > Advanced
    b. In the “Exclude from dynamic translation” section, input the CSS selectors of the elements you wish to exclude. This ensures these elements are not processed for dynamic translation, reducing AJAX requests.

    B. Disable Dynamic Translation Entirely:
    If dynamic translation isn’t crucial for your site’s functionality, consider disabling it:
    *Go to Settings > TranslatePress > Advanced
    *Enable the “Disable dynamic translation” option. This stops TranslatePress from processing content loaded via JavaScript, thereby reducing AJAX requests.
    Note: Disabling dynamic translation means content added to the page via JavaScript after the initial load won’t be translated automatically.

    C. Switch to WordPress Native AJAX Handling:
    In some server environments, using the default trp-ajax.php can lead to performance issues. Switching to WordPress’s native admin-ajax.php for handling AJAX requests might help.
    In this case, install this plugin (revert to admin ajax — https://translatepress.com/download/1151690/) to switch to a WordPress native approach.
    The only drawback is that on some large websites it can be a bit slower to translate front-end dynamic texts.

    D. Optimize Server Resources:
    High CPU usage can also result from insufficient server resources. Consider the following:
    *Upgrade Hosting Plan: Ensure your hosting plan provides adequate CPU and memory for your site’s needs.
    *Implement Caching: Utilize caching plugins to reduce server load by serving static versions of your pages.
    *Review Other Plugins: Some plugins can cause high CPU usage. Regularly audit and disable unnecessary plugins.

Viewing 1 replies (of 1 total)

The topic ‘?trp-edit-translation=preview’ is closed to new replies.