Developer forum

Forum » Rapido » Can I prevent a product list to use dynamicweb caching?

Can I prevent a product list to use dynamicweb caching?

Peter Leleulya
Reply

Can I prevent a product list to use dynamicweb caching?

I have a macro which is used by the product index.

The value of the macro is depending on user actions.

But the macro doesn't get hit everytime a productlist is shown, so it must be some caching causing that ...

What is the use of a custom macro if it isn't used ... so it's probably a setting somewhere, but I cant find it ...

 


Replies

 
Nicolai Pedersen
Reply

The server response is not cached.

If the same product list is shown twice with the same parameters (querystring), the browser caches the result of the json call.

If you add a timestamp or something like that, it should not cache.

You can check in the developer tools what the URL to the server is and see if it gets called second time - and try to run the ajax url directly in the browser and check if it changes.

BR Nicolai

 
Peter Leleulya
Reply

Thanks for your reply Nicolai.

If you meen to extend the feedFullUrl variable in ProductRenderer.cshtml, that doesn't seem to help.

string feedFullUrl = pageUrl + "&feed=true";
    feedFullUrl += !isFavoriteList ? "&DoNotShowVariantsAsSingleProducts=True" : "";
    feedFullUrl += "&timestamp=" + DateTime.Now.Ticks; 

In the DOM network inspector I see a 200 status and a 301 status per page load.
And I see my timestamp like so: ......?feed=true&DoNotShowVariantsAsSingleProducts=True&timestamp=636916923458197365

But the Macro doesn't get hit and the same 'wrong' products are shown.

When I click logoff my macro DOES get hit and the correct products are shown.
After that the macro doesn't get hit anymore ...

 
Nicolai Pedersen
Reply

Ok, then there is a call to the server to do an updated query? And is the response of those 2 calls different or the same when looking at the response in dev tools?

How do your macro look like? Can we see the code?

 
Peter Leleulya
Reply
First I see the raw default.aspx call which has no valid response, it redirects to a beautified call which does have a valid JSON product feed:
 
301 https://myproject.localhost/Default.aspx?ID=52&groupid=123&feed=true&DoNotShowVariantsAsSingleProducts=True&timestamp=636916951478523951
response: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
 
200 https://myproject.localhost/en/page-name/category/subcategory?feed=true&DoNotShowVariantsAsSingleProducts=True&timestamp=636916951478523951
response: Valid JSON
 
The macro doesn't get hit and the wrong products are shown.
 
When I F5 the page the same happens, a 301 and a 200 but with a new timestamp value.
But still no Macro hit and still the same wrong products are shown.
 
I don't think there is anything wrong with my Macro, because it works perfectly WHEN IT GETS HIT ...
 
I'm not sure how this feed works, but when this 200 call is done I expect it to use the index query as specified on the page's catalogue module everytime it is called.
The index query used in the page's catalogue module has an EQUAL reference to my macro response value.
 
The index query is slimmed down to just:
 
Active (System.Boolean) Equal True
AND
Language ID (System.String) Equal Dynamicweb.Ecommerce.Context:LanguageID
AND
Manufacturer ID (System.String) Equal MyMacroName.MyMacroSupportedAction
AND
Parent Group IDs (System.String[]) Contains 118
 
 
I have breakpoints in my macro and they don't get hit somehow when calling the productlist page with the ProductsRenderer.cshtml template.
Strangly enough EVERY TIME I logoff while I'm on the product list page the macro DOES get hit and does exactly what I expect it to do on every product list page load ...
 
Peter Leleulya
Reply

I will send you some info by email.

 
Peter Leleulya
Reply

It seems to happen when a group id is in the url … does this ring a bell to anyone?

/Default.aspx?ID=52&feed=true                                  <-- my macro DOES get hit

/Default.aspx?ID=52&groupid=123&feed=true           <-- my macro does NOT get hit

It is probably some settings issue, but can't figure out what ...

 
Nicolai Pedersen
Reply

Which version?

 
Nicolai Pedersen
Reply
This post has been marked as an answer

GroupID is a builtin Dynamicweb parameter that will be handled by the Ecommerce app - unless your query handles that parameter. So you need to specify GroupID as a parameter on your query.

Votes for this answer: 1
 
Peter Leleulya
Reply

Thanks NIcolai, I have been too rigorous in cleaning up demo functions.
The GroupID param did the trick.
1000 thanks for that tip and your support on this issue.

 
Nicolai Pedersen
Reply

Glad you found it! And always good to keep things clean - I see a lot of mess out there!!

BR Nicollai

 

You must be logged in to post in the forum