1 # How to set rich media cache ttl based on image ttl
4 Richmedia are cached without the ttl but the rich media may have image which can expire, like aws signed url.
5 In such cases the old image url (expired) is returned from the media cache.
7 So to avoid such situation we can define a moddule that will set ttl based no image.
9 The module must have a `run` function and it should be registered in the config.
16 image_url = Map.get(data, :image)
17 # do some parsing in the url and get the ttl of the image
19 ttl = parse_ttl_from_url(image_url)
20 Cachex.expire_at(:rich_media_cache, url, ttl * 1000)
28 config :pleroma, :rich_media,
29 ttl_setters: [Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl, MyModule]
32 > For reference there is a parser for AWS signed URL `Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl`, it's enabled by default.