Motivation: When not using hot-links, in presence of reverse proxys (like varnish) the redirection returned lacks of a Cache-Control header, causing redirection loops (in theory the browser itself could cache the response ending in the same loop).

This patch adds a Cache-Control header which avoids that scenario.

Also it avoids returning a redirection at all when the requested image is a derivative and we fetched the original successfully.

Comments

NITEMAN created an issue. See original summary.

niteman’s picture

greggles’s picture

Status: Active » Needs review
asrob’s picture

Status: Needs review » Reviewed & tested by the community

I've just successfully applied this patch in 8.x-1.x. AFAIK that cache-control header is valid.

greggles’s picture

Status: Reviewed & tested by the community » Needs work

One nitpick: the new comment about proxies needs closing punctuation for code style.

niteman’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB

Thanks for your quick review!

Sorry about the code style mistake. I've uploaded a new patch with closing puntuation.

asrob’s picture

Status: Needs review » Reviewed & tested by the community

Works well, thanks greggles and NITEMAN!

markdorison’s picture

RTBC.

geek-merlin’s picture

Issue tags: +Needs backport to D7

Great stuff. Looks like it also should be backported.

geek-merlin’s picture

Picked the cache-control-header, left the original-file condition which was obsoleted in #2840952-13: Hotlink does not redirect to imagestyle path

  • axel.rutz committed 4c2641b on 8.x-1.x authored by NITEMAN
    Issue #2719737 by NITEMAN: No-hotlink: use cache-control header (avoid...
geek-merlin’s picture

Status: Reviewed & tested by the community » Fixed
geek-merlin’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Fixed » Active

@NITEMAN: Just for curiosity: can you elaborate why we need the cache-control-header for fetch-file, but not for hotlink?

Also reopening to backport for D7.
See stage_file_proxy_init(), stage_file_proxy_process_file_uri().

geek-merlin’s picture

Status: Active » Fixed

While the D8 implementation first writes to disc and then does a redirect, D7 fetches, writes and delivers the result.

No redirection here, so does not apply to D7.

geek-merlin’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.