Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7892909
howto_set_richmedia_cache_ttl_based_on_image.md
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1006 B
Referenced Files
None
Subscribers
None
howto_set_richmedia_cache_ttl_based_on_image.md
View Options
#
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
.
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Thu, Oct 2, 4:42 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
474909
Default Alt Text
howto_set_richmedia_cache_ttl_based_on_image.md (1006 B)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment