TOPIC: Custom Fields in template - Joomla global cache

Custom Fields in template - Joomla global cache 13 Apr 2018 17:44 #2149

Hi

I have got some caching issue with Custom Fields so I thought I ask the experts.

I need to add some enhanced ecommerce tags to standard Google Analytics tracking on few pages. I created a custom field for testing - name: 'ec-js' containing extra JS for pages that need it. I'm using the following overrides:

article default.php with the following PHP: (image as code is rejected probably for security reasons)

https://drive.google.com/open?id=1MTGgV_DkveVaYEJnzrbz6Hy0CbVy6UbL

then add to template.php:

https://drive.google.com/open?id=1vWfglJr_SFrcdX7mPpCAr5tgU8ar2u0S

The result is GA JS with enhanced ecommerce tags nicely injected when needed - only with caching disabled.

If I enable Joomla conservative cache the 'ec-js' field is no longer injected meaning the values of the array are not cached and are only available on 1st page load. Any successive page load e.g. 2nd or 3rd results in nothing injected as content of the array is not cached for some reason.

How do I make contents of that array cached via just Joomla Conservative cache? Not sure if it helps but if I enable progressive cache the same problem occurs.

BTW - if I enable JotCache all is well as I think the whole page is nicely cached but I'm not using JotCache at the moment due to some issues with JCH 5.2.2.7 - I'm getting 404s for a short period when cache expires for JS and CSS. I will create a post for that but sorting GA JS is priority for now.

Joomla version : 3.8
JotCache version :
site template:
system plugins : all disabled for testing
The administrator has disabled public write access.

Custom Fields in template - Joomla global cache 14 Apr 2018 16:45 #2151

This request is very specific, outside JotCache forum topics. But anyway some hints for you:
- for correct operation with enabled cache you need access to dynamic changed data with ajax call (from js script)
- do not use $GLOBALS variable as the storage for dynamic data. Use Joomla standard approach for store/retrieve user related dynamic data in session variable.
The administrator has disabled public write access.
Time to create page: 0.288 seconds
We have 31 guests and no members online
Copyright © 2015 JotComponents
We have 31 guests and no members online
Copyright © 2018 JotComponents