Has cache=false stopped working?

iamgerardm
Shopify Partner
2 0 0

We had implemented some JSON view pages for a client that relied on the ?cache=false URL parameter. Recently however it seems this has stopped working on the live theme. It does appear to still work when previewing a theme. 

 

Has anyone else experienced this or have any insight?

Replies 19 (19)

MatthiasP
Visitor
1 0 1

Got the same issue. Any news about this problem?

iamgerardm
Shopify Partner
2 0 0

I had reached out to support last week but they were not very helpful. It seemed the person I was dealing with was not even aware of the feature. At this point I am still without a solution. Was hoping Jason (freakdesign) would have chimed in as he seems to be the one of the only places on the internet referencing it.

andrew_hawke
Shopify Partner
2 0 0

I have this problem as well. I've logged a job with Shopify Support but no response yet.

 

I'm using it to pass a query parameter to the page and that determines what featured collection gets displayed

 

Anyone have a solution or know what is going on

Jason
Shopify Expert
11190 225 2283

cache=false was never an officially documented property so using it was a bit of a hack. I've used it before in some old builds, and I've got a bunch of blog posts on the topic. However, being undocumented I also knew the lifetime was limited, and it could be removed at any point. Opting to not return cache has performance concerns for everyone.

 

I'd be suggesting that devs look into alternate approaches that use JavaScript instead, or leverage other aspects of Shopify like search results, filtered collections, alternate templates, etc that can return the data set you need. 

 

If you're using a querystring to determine what collection to show (since that's the most recent post in this thread) that sounds like something you could achieve with JS.

 

If you have absolute must have use cases I'd be interested to know what they are.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
Nico4
Shopify Expert
25 0 10

Interestingly, Using JS (AJAX) to do the requests will have to rely on cache:false in the XHR call to achieve the same result.

Kind of defeat the purpose of killing the cache=false. Sad move!

ChintanKotadia
Tourist
15 0 2

Experiencing the same issue. 😞 If you open the request in new window/tab then it will provide you fresh content whereas in ajax request cached content is loaded. Any work around for this one? We have lots of things which are dependent on this one in our store. 

 

Shopify should provide alternate method for this one. 🙂

Chintan Kotadia | Shopify Expert & Partner | Skype: kotadiachintan

Was my reply helpful? Click Like to let me know!
Was your question answered? Click Accept as Solution
Paul_West
Shopify Partner
250 9 68

I put a fake parameter on the end of the url based on the milliseconds of the current time of the request, which shopify ignores, but which causes it to not be cachable. e.g. &cache=20394823 - different value every time.

 

joaohorta
Shopify Partner
2 0 5

Paul_West I've tried that approach with no success. Any other possible option to solve this issue?

I have a special page (not a product one) that will load a different product depending on the query string. I can't think of another way of solving this problem.

Thanks!

ChintanKotadia
Tourist
15 0 2

Hi @joaohorta ,

 

I know its late. But you can always load product without using query string with normal Shopify way. Following is my approach:-

 

1. Create a new product template called "product.alternate.liquid".

2. In this template, make sure that layout selected should be none.

{% layout none %}
{% capture output %}
{% comment %}All the product condition goes over here {% endcomment %}
{% endcapture %}
{
  "product" : {{ output | json }}
}

3. For calling this template, javascript code will be follows :-

$.ajax({
  url: '/products/<product-handle>?view=alternate',
  method: 'GET',
}).done(
  function(response) {
    //parse the response
  }
);

I hope, this might help out. After Shopify disabled cache: false, I'm using this alternate solution for fetching product details.

 

Thanks!

Chintan Kotadia | Shopify Expert & Partner | Skype: kotadiachintan

Was my reply helpful? Click Like to let me know!
Was your question answered? Click Accept as Solution
XBRANDONX
Shopify Partner
23 0 4
Chintan your suggestion looks interesting. Do you think I can use it in a collection template that outputs xml? I'm using this but the output is cached:
https://business.czarto.com/2016/11/22/shopify-diy-facebook-product-feed/
ChintanKotadia
Tourist
15 0 2

Hi @XBRANDONX ,

 

Yes, you can also use this approach in collections pages. Since you want to post these feeds in Facebook or Google then there is no need of javacript approach. 

{% layout none %}
{% comment %} Iterate through products which are available in the collection{% endcomment %}
{%- for product in collection.products %}
  ......
{%- endfor -%}

Don't forgot to use pagination. You will not be able to get more than 50 products at a time. This is limitation of Shopify.

 

Thank you!

Chintan Kotadia | Shopify Expert & Partner | Skype: kotadiachintan

Was my reply helpful? Click Like to let me know!
Was your question answered? Click Accept as Solution
ChintanKotadia
Tourist
15 0 2

Hi @XBRANDONX 

 

One more thing, if you can provide your store URL then it will help me to debug more efficiently. Please feel free to send me private message.

 

Thank you!

Chintan Kotadia | Shopify Expert & Partner | Skype: kotadiachintan

Was my reply helpful? Click Like to let me know!
Was your question answered? Click Accept as Solution
XBRANDONX
Shopify Partner
23 0 4

@ChintanKotadia wrote:

Hi @XBRANDONX 

 

One more thing, if you can provide your store URL then it will help me to debug more efficiently. Please feel free to send me private message.

 

Thank you!


Hi Chintan, the feed is working perfectly and integrates to FB without issues. The problem is that the output  is CACHED hence my posting on this thread.

 

XBRANDONX
Shopify Partner
23 0 4

Actually, the problem is that Facebook is caching the page output on THEIR server

 

So my page store.com/collections/facebook-xml-feed-2 outputs:

 

<?xml version="1.0"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0"><channel>
<title>yyyyyyyy</title>
<link>yyyyyyyyyyyy</link>
<description></description> 


<item>

<g:title>yyyyyyyy</g:title>
<g:description>yyyyyyyyyyyyyy</g:description>
<g:link>yyyyyyyyy</g:link>
<g:google_product_category>Apparel &amp; Accessories > Clothing > Shirts &amp; Tops</g:google_product_category>
<g:item_group_id>1328732602479</g:item_group_id>
<g:id>14559197462639</g:id>
<g:condition>new</g:condition>
<g:price>0.00 ZAR</g:price><g:availability>out of stock</g:availability>
<g:image_link>yyyyyyyyyyyyyy</g:image_link>
<g:brand>yyyyyyyyyyyyy</g:brand>
<g:mpn>yyyyyyyyyyyy</g:mpn>
<g:product_type>T-Shirts</g:product_type>
<g:age_group>adult</g:age_group>

<g:size>Small</g:size><g:size_system>US</g:size_system>
<g:gender>male</g:gender>
<g:custom_label_0>lastchance</g:custom_label_0>
<g:custom_label_1></g:custom_label_1>
<g:custom_label_2></g:custom_label_2>
<g:custom_label_3></g:custom_label_3>
<g:custom_label_4></g:custom_label_4>
<g:shipping_weight>0.7 kg</g:shipping_weight>
</item>

 etc

 

 

But. Facebook (correctly) keeps a cache of this page on it's scraping server thinking it's a web url.

I can clear this cache by using the Facebook Debugger to scrape it again and get new content. But this doesn't help when the Facebook Catalog data feed auto schedules a load every hour and won't see the updated content.

 

Perhaps if I knew how to make the output have the .xml extension FB wouldn't cache it?

Anyone?

 

Oboroten
Shopify Partner
2 0 7

Hi!

All the above methods do not work, pages with different GET parameters are also cached. We did a little research and found out that there are parameters that Shopify does not cache, for example, 'quantity' and 'type', maybe there are others. Now we pass the current timestamp to 'type' and everything works fine.

stumblor
Visitor
1 0 0

Legend!! Nice find. 🙂

XBRANDONX
Shopify Partner
23 0 4

I have a case where I am using this :

https://business.czarto.com/2016/11/22/shopify-diy-facebook-product-feed/

to create a facebook xml feed.

When Facebook scrapes the output it never gets the latest version and caches it's first response. I presume this is the Shopify cache working in the network between Facebook and Shopify (Cloudflare?).

 

So..

 

How to best signal that this page shouldn't be cached? I'm currently testing using cache=false

JohnAtFisharply
Tourist
4 1 1

My use case is that I want my contact form to receive the product information from the product page that the user came from so that I can populate the data into the form that will be submitted. 

What other options are there? &cache=false is having very mixed results for me, assumedly because of caching behavior.

ChintanKotadia
Tourist
15 0 2

Hi @JohnAtFisharply ,

 

I didn't understand your use case. But, I think my above response might help you out as well if you're willing to fetch product information. 

 

Thank you.

Chintan Kotadia | Shopify Expert & Partner | Skype: kotadiachintan

Was my reply helpful? Click Like to let me know!
Was your question answered? Click Accept as Solution