• Resolved dineshravajani

    (@dineshravajani)


    Hello Guys,

    I have a custom login form on my website. I also use nonce on that custom login form.
    When user enter their username and password and click on “login” button, it executes custom AJAX call. To verify nonce, i use this function wp_verify_nonce() but sometimes this function return false.

    But when i try to clear all cache from W3 Total Cache from WP-ADMIN, then my login form works correctly.

    Is there a way to Auto-Flush the cache after a specific time ?

    Thank you in advance !

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @dineshravajani

    Thank you for yoru question and I am happy to assist you with this.
    First, you should make sure that the Caching is not enabled for logged-in users in Performance>Page Cache>”Don’t cache pages for logged-in users”.
    To answer your other question, W3 Total Cache does not have an option to purge the cache at a specific time.
    You can, however, set up a custom cron on your server and call w3tc_flush_all(); in a specific time interval every X hours/minutes.
    Please confirm that the caching is disabled for logged-in users and also, try to disable the Performance>Browser Cache>HTML&XML>set expires header and Cache-control header.
    Thanks!

    Thread Starter dineshravajani

    (@dineshravajani)

    Hello @vmarko

    Thanks for your quick reply.

    Is there anyway not to cache nonce value ?

    Currently this checkbox is checked currently “Don’t cache pages for logged in users”
    https://prnt.sc/1eclc5j

    In addition to this, these two checkboxes are disabled. https://prnt.sc/1eclvtw

    1. Set expires header
    2. Set cache control header

    Do let us know if i miss anything else.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @dineshravajani

    Thank you for the information.
    The problem is with the nonce lifespan which is usually 12 hrs and the fact that the page is cached. Since W3 Total Cache does not have cache expiry, meaning if the page is cached it will remain cached until the cache is purged manually or defined in the Performance>Page Cache>Purge policy.
    There are a couple of things that you can do in this case.
    The first one is the same as I’ve shared in the previous answer and that is to set up a custom cron job on the server and call w3tc_flush_all(); every 12 hrs for example.
    The other thing that you can do is to set up a cache Preload in Performance>Page Cache>Cache Preload to Automatically prime the page cache. With this, you can manage Update interval: The number of seconds to wait before creating another set of cached pages.
    Also, there is an option Garbage collection interval: which If caching to disk, specifies how frequently expired cache data is removed. For busy sites, a lower value is best.

    To sum up, nonce and caching are not the best friends. but there are a couple of solutions as mentioned above that can work.
    I hope this helps and let me know if you have any other questions.

    Thanks!

    Thread Starter dineshravajani

    (@dineshravajani)

    Hello @vmarko

    Thanks for your quick response and detail explanation regarding the issue which i am facing.

    As per your suggestion in previous comment, I have enabled checkbox “Automatically prime the page cache” at here

    Performance>Page Cache>Cache Preload to Automatically prime the page cache.

    https://prnt.sc/1edaqi6

    Can you please let me know your comment on my below two points.

    1. By enabling checkbox “Automatically prime the page cache” will it solve “nonce” issue ?

    2. My site will be having lots of user which means heavy traffic, so can you please let us know which value will you recommended to use in “Update interval:” textbox https://prnt.sc/1edc0kt

    Thanks in advance.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @dineshravajani

    Thank you for yoru question.
    The default values are “the best” values and should not cause a lot of server resource consumption when preloading pages.
    Please make sure to add the sitemap to the Sitemap URL: field as W3TC needs the sitemap to know which pages should be cached.
    What the Cache preload does is:
    – Check the last offset
    – Check how many URLs are allowed to be processed per run
    – Fetch all URLs from sitemap (even nested sitemaps work)
    – Loop through a set of URLs to visit them
    If the end of the list is reached, it will start from the beginning of the next run. That means that when the last page is reached, it will start from the beginning with the first 10 pages and so on (10 pages if the default values are set).
    So if for example, you have 1000 pages, and you set the Update interval to 900s (15 mins), and the Pages per interval is set to 10, it means that your entire website is going to be cached in approximately 24 hrs.
    You can of course increase the number of pages you want to be cached in a batch or lower the update interval.

    I hope this helps!

    Thread Starter dineshravajani

    (@dineshravajani)

    Hello @vmarko

    Thank you for your reply.

    I need to wait for few days around 3-4 days in-order to see if i am again getting nonce issue or not as this issue is occurring for every 72 hours. I had already applied all the settings in WP_ADMIN.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @dineshravajani

    Thank you for the information.
    Let me know if the issue persists.
    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Nonce Issue on Custom Login Form’ is closed to new replies.