• Resolved Rafael UJ

    (@rafaeluj)


    Hey Phil!

    I have been working heavily on optimising our page with litespeed plugin connected to a CDN and my limited PHP knowledge is stopping me from generating a public cache for pages. I would try the V3 to see if that would solve my problem but unfortunately I do not meet PHP version requirements so at the moment I am stuck with the previous version… I can not seem to exclude this variable from caching as a vary:

    </label></p><input type=”hidden” name=”age_gate[age]” value=”TVRnPQ==” /><input type=”hidden” name=”action” value=”age_gate_submit” /><input type=”hidden” name=”age_gate[nonce]” value=”832ce7b546” /><input type=”hidden” name=”_wp_http_referer” value=”/product-category/e-liquid/xxx/” /><input type=”hidden” name=”confirm_action” value=”0″ /></form></div></div>

    As you can imagine every time the age gate is generating 832ce7b546 new page is being made making the cache useless. I had a very similar issue with another plugin called WCPA that generated values inlined but I managed to make a vary entry in my .htaccess file forcing it as a “random” unique so my public cache remains intact.
    The code after looked like this:

    var wcpa_global_vars = {"wc_currency_symbol":"\u00a3","wc_thousand_sep":",","wc_price_decimals":"2","wc_decimal_sep":".","price_format":"%1$s%2$s","wc_currency_pos":"left","date_format":"F j, Y","date_format_js":"MMMM D, YYYY","time_format":"g:i a","time_format_js":"h:mm a","use_sumo":"","start_of_week":"1","today":{"days":18713,"seconds":1616834724},"google_map_api":"","google_map_countries":"","ajax_url":"https:\/\/xxxxxxxx.xx.xx\/wp-admin\/admin-ajax.php","change_price_as_quantity":"","show_field_price_x_quantity":"","show_strike_product_price":"","strings":{"ajax_file_upload":"Files are being uploaded...","ajax_upload_error":"Upload error","sel_min_req_error":"You have to select minimum %d items","sel_max_req_error":"You can select maximum %d items","fix_val_errors":"Please correct the errors shown for fields","field_is_required":"This field is required","character_not_valid":"Character %s is not supported","sumo_strings":{"captionFormat":"{0} Selected","captionFormatAllSelected":"All {0} selected!"}},"wcpa_init_triggers":["qv_loader_stop","quick_view_pro:load","elementor\/popup\/show","xt_wooqv-product-loaded","woodmart-quick-view-displayed","porto_init_countdown"]};

    So that was straightforward – I grabbed the identifier and made a caching rule that looked like this:

    RewriteEngine on
    RewriteRule .* – [E=Cache-Vary:wcpa_global_vars]

    If the 832ce7b546 was identified as something else other than

    value=””

    I would probably put it inside the same scheme and forget about it but this identifier is too generic and it is used across multiple functions so I can not possibly use it.

    In the code I have noticed

    name=”age_gate[nonce]”

    and I thought – oh, great, I can put it through ESI content that is private for every user but that made no difference. The code is still there and it is being inlined into the page.

    Any insight into my issue would be greatly appreciated. ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Rafael UJ

    (@rafaeluj)

    Update: I tried to make a vary out of the whole RewriteRule .* - [E=Cache-Vary:tmpl-age-gate] but to no avail.

    I excluded tmpl-age-gate from optimised JS – testing.

    Thread Starter Rafael UJ

    (@rafaeluj)

    No changes, the code is still in every page

    Plugin Author Phil

    (@philsbury)

    Hi @rafaeluj,

    The nonce field isn’t actually used in the JS version, I could remove it from the template if that’s helpful?

    Cheers
    Phil

    Thread Starter Rafael UJ

    (@rafaeluj)

    Hey Phil!
    Thx for the reply!

    the whole part of this script type="text/template could be removed I suppose..
    I mean this block:

    <script type="text/template" id="tmpl-age-gate">
    
    <blockquote>  <div class="age-gate-wrapper"><div class="age-gate-background-colour"></div><div class="age-gate-loader"><svg version="1.1" class="age-gate-loading-icon" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve"><path opacity="0.2" d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946 s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634 c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"/><path d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0 C22.32,8.481,24.301,9.057,26.013,10.047z"><animateTransform attributeType="xml"
                attributeName="transform"
                type="rotate"
                from="0 20 20"
                to="360 20 20"
                dur="0.5s"
                repeatCount="indefinite"/></path></svg>    </div><div class="age-gate"><form method="post" action="https://ultimatejuice.co.uk/product-category/e-liquid/ultimate-juice-brands" class="age-gate-form"><h1 class="age-gate-heading">Ultimate Juice</h1><div class="age-gate-error" data-error-field="buttons"></div><p class="age-gate-challenge">Are you over 18 years of age?</p><button type="submit" value="1" name="age_gate[confirm]" class="age-gate-submit-yes">Yes</button><button type="submit" name="age_gate[confirm]" class="age-gate-submit-no">No</button><p class="age-gate-remember-wrapper"><label class="age-gate-remember"><input type="checkbox" name="age_gate[remember]" value="1" checked="checked"  />
                Remember me          </label></p><input type="hidden" name="age_gate[age]" value="TVRnPQ==" /><input type="hidden" name="action" value="age_gate_submit" /><input type="hidden"  name="age_gate[nonce]" value="c8aa474bf5" /><input type="hidden" name="_wp_http_referer" value="/product-category/e-liquid/ultimate-juice-brands/" /><input type="hidden" name="confirm_action" value="0" /></form></div></div>

    I believe it is generated by age-gate-shortcode, if I remove the script will this stop the JS version from working? Or is there another way? Line of code perhaps?

    because what’s tripping up my whole optimization is just this part:

    value=”c8aa474bf5″

    Thank you for your time brother!

    • This reply was modified 3 years, 8 months ago by Rafael UJ.
    • This reply was modified 3 years, 8 months ago by Rafael UJ.
    Thread Starter Rafael UJ

    (@rafaeluj)

    I was working to upgrade the PHP to 7.4 – would installing V3 alleviate this issue?

    Plugin Author Phil

    (@philsbury)

    Hi @rafaeluj,

    Yeah, removing the whole script would break it entirely as that’s what we grab if there need to be an age gate on the page (shortcode is a different one).

    value=”c8aa474bf5″

    This is the nonce value and would change for new users. V3 has it too but we don’t really need it on the front end so I may well remove it.

    This is a version of v2 with that field removed if you want to see if it helps.

    Thanks
    Phil

    Thread Starter Rafael UJ

    (@rafaeluj)

    That worked like a charm! Phil you’re da MVP! ????
    Thank you so so much!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Inline variable exlusion – optimisation issues’ is closed to new replies.