• Resolved txtcoke

    (@txtcoke)


    Hello, I am having an issue with the plugin and admin-ajax.php

    My site uses admin-ajax for loading ajax loaders or showing more products on pages etc.

    When I for instance press the “more products button”, where products load over admin-ajax, nothing happens. The loader keeps loading infinitely.
    Then I checked the browser console, and I saw admin-ajax.php is returning 401.

    When I clear the plugin cache, everything starts working again, but after some hours, admin-ajax again is 401, and consequently, all loaders that rely on it don’t work, keep loading forever as I mentioned.

    I’ve already whitelisted the path on the plugin settings, and it didn’t work.
    Then, I made a last check, deactivating the plugin, and finally, I could see it was a plugin issue, as the error disappears completely, and things load properly when admin-ajax is called.

    Why is that so?
    I love the plugin, I don’t want to stop using it.
    What I also don’t understand is why when I clear plugin cache, admin-ajax works properly, and shortly after (some hours), it starts again returning 401 on the browser console.

    Note: This issue never happens on the backend, when I am logged in as admin.

    How can I solve it?
    Thank you!

Viewing 8 replies - 1 through 8 (of 8 total)
  • @txtcoke Could you please try to purge the cache and the from WP-Optimize > Cache > Preload, click Preload button to preload all the urls and check if it helps to fix the issue?

    Thread Starter txtcoke

    (@txtcoke)

    Hello I did it to test, but the behavior is the same, after some hours error 403 admin-ajax.php was showing up again, and nothing that relies on ajax was loading…
    (Sorry in my first message I told 401, but it is 403 error)

    @txtcoke Have you performed a conflict test yet?

    If not – first, please make a full site backup.

    Try deactivating all plugins except for WP-Optimize and see if it is resolved.

    If so, reactivate each plugin one at a time until you find the culprit. You can check for the issue between activating each plugin, so you can see which one is causing problems.

    Please let us know your findings.

    Thread Starter txtcoke

    (@txtcoke)

    Hello, that method wont work as i mentioned when cached is recently cleared issue is not there. So even though I activate plugin by plugin, I wont find anything as everything will seem to work well as the cache would be new.
    Issue happens some hours to a day after cache has been flushed.

    @txtcoke 403 Forbidden usually occurs when your server is blocking the request, could you please check with your hosting company, if they have any rules added to block the request?

    Thread Starter txtcoke

    (@txtcoke)

    Hello, I’ve already checked it with them. This path is whitelisted on server.
    I see it comes from the plugin as I had to change the cache plugin, and the issue is not happening with other cache plugins.
    To be honest I am very sorry because your plugin is the best I used and id like to continue to use it.
    I would appreciate if you could find out why it happens.
    I see there were other people who had same issue searching on the forum..
    So it seems it didn’t only happen to my site.
    Thank you

    Hi @txtcoke,

    This sounds like the ajax requests are including a nonce, which will expire after a few hours, making the request fail.
    If these requests are for non-logged in users and / or do not have any user-specific content, the use of a nonce doesn’t really make sense.

    If you authored the code for these ajax calls, I would recommend removing the use of nonces, IF the content fetched is not user specific.

    Otherwise you can try reducing the lifespan of the cache to a few hours.

    Best,
    Marc

    Thread Starter txtcoke

    (@txtcoke)

    Can I “whitelist” nonces?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Admin-ajax.php issue’ is closed to new replies.