summaryrefslogtreecommitdiff
path: root/docs/configuration/howto_set_richmedia_cache_ttl_based_on_image.md
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-10-10 14:40:59 +0200
committerlain <lain@soykaf.club>2019-10-10 14:40:59 +0200
commitc54ae662dcc08c0c04a1dff7bb7a361665e877b8 (patch)
treeafb9cce0d7bcc15cd2fe3221609d7883d45d0057 /docs/configuration/howto_set_richmedia_cache_ttl_based_on_image.md
parent02f8e2a8ab65c3e8497bab4576ce4e75f8df3217 (diff)
parent6355694309b0bad3687a8a7820b81ebf6625751d (diff)
downloadpleroma-c54ae662dcc08c0c04a1dff7bb7a361665e877b8.tar.gz
pleroma-c54ae662dcc08c0c04a1dff7bb7a361665e877b8.zip
Merge remote-tracking branch 'origin/develop' into benchmark-finishing
Diffstat (limited to 'docs/configuration/howto_set_richmedia_cache_ttl_based_on_image.md')
-rw-r--r--docs/configuration/howto_set_richmedia_cache_ttl_based_on_image.md33
1 files changed, 33 insertions, 0 deletions
diff --git a/docs/configuration/howto_set_richmedia_cache_ttl_based_on_image.md b/docs/configuration/howto_set_richmedia_cache_ttl_based_on_image.md
new file mode 100644
index 000000000..bfee5a9e6
--- /dev/null
+++ b/docs/configuration/howto_set_richmedia_cache_ttl_based_on_image.md
@@ -0,0 +1,33 @@
+# How to set rich media cache ttl based on image ttl
+## Explanation
+
+Richmedia are cached without the ttl but the rich media may have image which can expire, like aws signed url.
+In such cases the old image url (expired) is returned from the media cache.
+
+So to avoid such situation we can define a module that will set ttl based on image.
+The module must adopt behaviour `Pleroma.Web.RichMedia.Parser.TTL`
+
+### Example
+
+```exs
+defmodule MyModule do
+ @behaviour Pleroma.Web.RichMedia.Parser.TTL
+
+ @impl Pleroma.Web.RichMedia.Parser.TTL
+ def ttl(data, url) do
+ image_url = Map.get(data, :image)
+ # do some parsing in the url and get the ttl of the image
+ # return ttl is unix time
+ parse_ttl_from_url(image_url)
+ end
+end
+```
+
+And update the config
+
+```exs
+config :pleroma, :rich_media,
+ ttl_setters: [Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl, MyModule]
+```
+
+> For reference there is a parser for AWS signed URL `Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl`, it's enabled by default.