1

I have two chunks of data in the same 'viewModel' template:

{!-- Getting data for kitchen list --}
{exp:stash:set_list
    name="kitchen_list"
    parse_tags="yes"
    save="yes"
    scope="site"
    refresh="1440"
    replace="no"
}
  {exp:channel:entries
    channel="kitchen_list"
    disable="member_data|pagination|categories"
  }
    {stash:title}{title}{/stash:title}
    {stash:url_title}{url_title}{/stash:url_title}
    {stash:url_title_path}{url_title_path='sky-island-natural-foods/whats-cooking'}{/stash:url_title_path}
    {stash:description_brief}{kitchen_description_brief}{/stash:description_brief}
    {stash:description_full}{kitchen_description_full}{/stash:description_full}
    {stash:photo_product}{kitchen_photo_product}{/stash:photo_product}
  {/exp:channel:entries}
{/exp:stash:set_list}

{!-- Getting data for kitchen list page --}
{exp:stash:set_list
    name="kitchen_page"
    parse_tags="yes"
    save="yes"
    scope="site"
    refresh="1440"
    replace="no"
}
  {exp:channel:entries
    channel="kitchen_page"
    disable="member_data|pagination|categories"
    limit="1"
  }
    {stash:title}{title}{/stash:title}
    {stash:sidebar_heading}{kitchen_page_sidebar_heading}{/stash:sidebar_heading}
    {stash:sidebar}{kitchen_page_sidebar}{/stash:sidebar}
  {/exp:channel:entries}
{/exp:stash:set_list}

It all works fine, but when I look at the stash table with Sequel Pro as I navigate the pages, it seems that the kitchen_list does not get rewritten to the database (I thought replace="no" took care of this) on each subsequent page visit, but kitchen_page does get rewritten every time I revisit a page which uses that data. So there are multiple row in the table for kitchen_page with identical data, just different IDs, but there is only one row for kitchen_list.

I expected that by caching the fragments of data and using replace="no", I would only see a single row in the stash table for that fragment, no matter how many times the stash list was called.

I can't tell if there is something off with my code, or just my assumptions/understanding of the caching. Thank you.

9
  • Using the template debugger, it seems every time the page loads, kitchen_page is SET and later RETRIEVED, whereas kitchen_list is simply RETRIEVED as it is already cached. I'm seeing this in a lot of my templates—stash lists that are set with caching are being SET on each page load rather than just retrieved once the cache has been written.
    – Jim
    Commented Nov 15, 2013 at 23:54
  • What version of stash are you using? i just now tested with 2.4.6 and can't reproduce this issue.
    – GDmac
    Commented Nov 16, 2013 at 8:26
  • Do you have cookies enabled in your browser? Are you using a subdomain with an underscore _ in the name? What timezone is your EE site set to and your server? Commented Nov 16, 2013 at 19:07
  • I'm using v2.4.6
    – Jim
    Commented Nov 16, 2013 at 22:08
  • Cookies are enabled, I see the exp_stashid cookie. I'm not using a subdomain locally. The timezone is America/Los_Angeles in ExpressionEngine and in my php.ini file. I have auto detect in the config for DST.
    – Jim
    Commented Nov 16, 2013 at 22:17

3 Answers 3

2

If your code above is in a Stash file (i.e., not a regular EE template), double-check to make sure that you have this Stash config set:

$config['stash_file_sync'] = TRUE;

I've had this happen to me a few times: I make a change in a Stash file, forget that I have that setting set to FALSE, and wonder why my code isn't working as expected.

1
  • The above code is in an EE template. The layout and partials are stash files, but the data templates are EE. My config is set to $config['stash_file_sync'] = TRUE; already. Thanks for response, though.
    – Jim
    Commented Nov 16, 2013 at 2:06
2

I'm afraid I cannot reproduce this problem. Logged in/out, cookies enabled or disabled, I find that the cached items are generated only once until they expire. Tested with both EE 2.6.1 and EE 2.7.2 and Stash 2.4.6.

To rule out a server vs php timezone configuration issue (where the expiry date may fall in the the past of the server) please try with refresh="0" (never expires).

You mentioned you are using a third party cache-breaking extension. Please remove this extension entirely from your system folder and make sure it is not listed in the exp_extensions table (if it is, delete the record). Make sure that the Stash extension IS installed.

Please truncate your exp_stash table, and delete your cookies for the testing domain.

Create a new template with only your code above in it, and view it.

Do you still have the problem? If so, as you are using scope="site" the session_id in the stash table for each variable should be _global. Is that the case or do you see a long string of characters?

1

I figured it out eventually. I am using a config bootstrap which I set up when I was first learning ExpressionEngine and haven't looked at it much since, apart from updating db settings etc.

I had: $config['enable_db_caching'] = "y";

and EE was caching the stash chunks before stash could which was causing all the trouble when I was logged in. I've turned this setting off in the config now and it is behaving as expected.

I now realize this setting was causing problems with some of the other modules I'm using. A few issues I've had now make sense!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.