Liquid, JavaScript, themes, sales channels
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?
Got the same issue. Any news about this problem?
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.
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
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.
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!
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. 🙂
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.
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!
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!
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!
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!
@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.
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 & Accessories > Clothing > Shirts & 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?
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.
Legend!! Nice find. 🙂
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
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.
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.
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024