How to Cache Globally Except for One Page I have a template element that is used on almost every page of the site. I would like to cache that element globally, except on one particular page I would like it to just be a normal cache based on the page URL.

The current code I'm using is below, which is not working as intended. The global cache is still working on entry id 126.

{% cache globally using key 'entry_' ~ entry.id ~ '_elements' unless entry is not defined or entry.id == '126' %}


What would be the best way to make that functionality work without slowing down any other pages? Thanks!
You could add a variable like globalCacheDisabled and {% cache globally using key 'entry_' ~ entry.id ~ '_elements' unless globalCacheDisabled %} and use a {% set globalCacheDisabled = entry.disableGlobalCache %} on the given page template.

On Craft's side I'd use a Lightswitch field on the entry with handle disableGlobalCache, which is disabled by default which you can then activate on the given entry/ies. 

This makes you prone to changing id's and differences across environments. (While testing make sure to purge the cache)