Lint
[akkoma] / lib / pleroma / plugs / uploaded_media.ex
index 69c1ab942769ca657a076fe5072d6163c56dcbd8..74427709d8af65ddbc1df7757131f866e3188ccc 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Plugs.UploadedMedia do
@@ -14,6 +14,8 @@ defmodule Pleroma.Plugs.UploadedMedia do
   # no slashes
   @path "media"
 
+  @default_cache_control_header "public, max-age=1209600"
+
   def init(_opts) do
     static_plug_opts =
       []
@@ -58,6 +60,10 @@ defmodule Pleroma.Plugs.UploadedMedia do
       Map.get(opts, :static_plug_opts)
       |> Map.put(:at, [@path])
       |> Map.put(:from, directory)
+      |> Map.put(:cache_control_for_etags, @default_cache_control_header)
+      |> Map.put(:headers, %{
+        "cache-control" => @default_cache_control_header
+      })
 
     conn = Plug.Static.call(conn, static_opts)