Publisher is EE6 compatible, but it does not support the Fluid field. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: {referrer} being cached.

Status Resolved
Add-on / Version
Severity Critical
EE Version 16

Jannis Gundermann

Jun 06, 2012

Hi!

I’ve got a template in which I’d like to use the URL Helper’s {referrer} to determine wether a user has reached a project page by clicking on the thumbnail from the homepage or from an overview listing and then build a “back” button to turn them back to the previous page.

Think of these three templates:

/ (grid with thumbnails of all types of projects)
/design/ (thumbnails of only design projects)
/design/project-title/ (specific project on which we have the Back button)

If user comes from / to /design/project-title/ the back button should point them back at /
If user comes from /design/ to /design/project-title/ the back button should point them back to /design/

My current logic is

{if "{referrer}" == "{homepage}"}path to homepage{if:else}path to type specific overview page{/if}

In the above example I’ve noticed that even if the 2 values (referrer and homepage) are identical the if statement will always return false.

To mitigate this I switched to using Switchee:

{switchee variable="{referrer}" parse="inward"}
    {case value="{homepage}"}
    Point to homepage
    {/case}

    {case default="yes"}
    point to section overview page
    {/case}
{/switchee}

The latter (using switchee) works well, but the problem I’ve identified is that it seems the value of {referrer} is being cached by having template caching turned on.

So if I navigate from / to /design/project-title/ the first time the referrer will be / and as such the back button is being written to point to the homepage.
If I now revisit this page but my origin page is /design/ then the back button still points to the homepage.

Is there any way of for example having {referrer random} to disable tag caching or is there any way (ideally without turning off template caching) to have this back button point to the correct page?

Thanks for reading,
Jannis

#1

BoldMinded (Brian)

Jun 06, 2012

If caching is the issue I’m not sure there is a fix in URL Helper b/c it just creates early parsed global variables every page load. If you disable tag caching does it work then?

#2

Jannis Gundermann

Jun 06, 2012

It seems {switchee} does not respond at all to either cache=“no” or “random” to stop the tag from caching but I’ve logged a separate support request with Mark (developer of Switchee) regarding this.

Turning off template caching for now is obviously working but it would be nice to be able to still cache the template somehow.

You’re right though, since your add-on is simply creating a bunch of global vars I will probably need to seek the help of the Switchee plugin creator and figure out a way to make his plugin not cache rather than look at the global vars.

Thanks for your feedback though, very much appreciated.

Login to reply