Doing a /_recache using a trigger


(Ian Hirst) #1

Matrix Version:5.5.3.3

I’d like to set up a trigger that recaches a page on our webserver when it is made live.

We are using Redis cache, rather than squid or the matrix cache, so the actions to clear the matrix or squid cache don’t work. Our way of recaching a page is to add /_recache to the end of the url.

Inspired by this post Trigger to clear Matrix cache and then Squid cache not working I’m thinking I can pass in the url of the page I want to recache to a ‘Call REST Resource’ action.

When I hardcode the address of a page, it works. What doesn’t work is when I pass in a keyword like %asset_url_path% as the url in the request (I’ve topped and tailed the path with the site domain and /_recache). Do keywords work in the Call Rest resource? If they do, would %asset_url_path% actually pick up the path of the asset creating the trigger?

Thanks in advance.


#2

Are you talking about the URL field on the Details screen? I use global keyword like %globals_asset_url:xxx% and it works.


(Ian Hirst) #3

Hi. Thanks for your reply. Yes this keyword works when the Call Rest Resource is a page in the site. However, I am calling it as a trigger action and it doesn’t appear to work there.


(Bart Banda) #4

Keywords work there, but %asset_url_path% will only get you the path of the URL, not the full URL which is needed as that’s usually what’s stored as the cache key (not sure about Redis though). Have you tried using %asset_url%? ALso, what is your trigger event?


(Ian Hirst) #5

I have tried using https://www.domain.com%asset_url_path%/_recache as well as %asset_url%/_recache but no joy. I get the error Curl Error (3): '': malformed [REST0001].

The trigger event is when an asset status is changed to live.


(Bart Banda) #6

I wonder if the keyword is not getting evaluated before the REST call is made. Can you try using %frontend_asset_url% or %globals_asset_url%?


(Ian Hirst) #7

Thanks Bart.

https://domain.com%asset_url_site_path%/_recache fixed it for me.


(Bart Banda) #8

Oh, interesting. Good to hear you solve it!