• i am using google forwarding numbers to track adwords, it works by replacing the phone number on my site with a google number when the visitor arrives via adwords.

    the cache is causing my number to always appear since it is cached. how do i instruct the cache to not cache the widget code/content so that the correct number displays?

    https://www.ads-software.com/plugins/wordfence/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter tsabar

    (@tsabar)

    i have found solutions on not caching an entire page, but the number widget appears on all pages. what if i want to stop caching just for the widget and not the entire page?

    Hi,
    Please let me know where exactly is your widget code that you don’t want to cache it? is it in a widget file in your theme? or this is part of a plugin? if so, which plugin?

    Generally, you can use doNotCache() function in your pages and Wordfence will stop caching any page request with this function call, the proper use of this function should be like that:

    if (class_exists('wordfence')) {
            wordfence::doNotCache();
    }

    I think you can call this function in your widget file.

    Let me know how it goes,
    Thanks.

    Thread Starter tsabar

    (@tsabar)

    it is the content of the widget, not the widget itself. i have sidebar widgets with my phone number wrapped by google code that i don’t want to cache.

    if i tend to use the same 3 widgets to display the phone, perhaps i can find the widget “pages” that are called and insert your code there?

    Are you adding this code in a normal “Text Widget”? please let me know the code you are using so I can give it a try at my end, you can use Pastebin, or send it to this email “alaa[at]wordfence.com”.

    Thanks.

    Thread Starter tsabar

    (@tsabar)

    Yes I am using a normal text widget to enter my phone number.

    Google’s code actually goes in the global header so there is no problem there.

    The call “function” is actually just my phone number which triggers Google’s code to replace my number with theirs.

    The only code I have in the text widget is:

    Call 1-800-100-100

    I need this line in the text widget to not be cached.

    Thread Starter tsabar

    (@tsabar)

    oops:

    <a href="tel:1-800-100-100" id="number_link">Call 1-800-100-100</a>

    Actually, this line is just a static code, it shouldn’t be considered when it comes to caching, will need to look at the main code snippet that control replacing your phone number with a Google one.

    Are you using this snippet mentioned here in (Part III > Example 3)?

    Thanks.

    Thread Starter tsabar

    (@tsabar)

    actually just the code in part 2, they said i don’t need part 3 if i insert the following line of code into part 2:

    var google_replace_number="1-800-100-100"; // << Replace with your phone number

    I’m not sure who do you mean by “they”?

    Please follow the three parts mentioned on this Google help page, and make sure everything is working fine without enabling Wordfence Caching, then re-check with “Basic Caching” turned on, and let me know the whole code you are using.

    Thanks.

    Thread Starter tsabar

    (@tsabar)

    Google instructed me to ignore Part 3, to insert Part 2 code ( + the var google_replace_number line I mentioned above) in the global header, and to insert just the phone number in the widget.

    The dynamic phone number works fine with no cache or with Basic Caching, the problem exists only with Falcon Engine.

    Is there no way to exclude the Google code in the header from the Falcon cache? Perhaps placing the Google code on a separate page and calling it into the header via the include function and then excluding that separate page?

    Actually, JavaScript codes should not be affected by any kind of caching, you could try clearing the cache completely by deleting everything under this directory /wp-content/wfcache, then re-check your page, hope this helps!

    On the PHP code level, we only offer doNotCache() function, so any page includes this function will be excluded from caching.

    Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘how to exclude widget content from cache?’ is closed to new replies.