[FFmpeg-devel] [PATCH] http: make caching of redirect url optional

Eran Kornblau eran.kornblau at kaltura.com
Mon Nov 8 08:15:11 EET 2021


> 
> On Tue, 2 Nov 2021, Eran Kornblau wrote:
> 
> > Hi all,
> >
> > The attached patch makes the default behavior of caching HTTP redirects optional.
> 
> Is caching a redirected URL allowed per the HTTP spec? If not, then no caching should take place, or the caching should be optional, and not the default.
> 
From a quick search on this, it seems that browsers by default cache 301 redirects, while 302/307 are not cached by default.
However, in both cases, the browser is expected to honor any Cache-Control/Expires headers.

Changing the implementation to imitate the behavior of a browser would be more complex, since currently there is only a single "slot" in the cache.
For example, if we have a chain of redirects 307->301->200, and we want to cache the 301 but not the 307, we can't really do it.
Solving this one would require a more complex data structure, and if we add expiration/TTL to the mix, it becomes even more complex...

Assuming we don't want to add a large chunk of code to handle this, the options I see are -
1. A simple boolean option - as proposed in this patch. We can argue about what the default should be :) but it felt safer to me to have the default behavior as it was before.
2. Cache only 301's directly linked to the original URL - e.g. if we have 301->301->307->301->200, we cache only the first 2 redirects.
My concern here is that this would break/slow down applications that rely on the existing behavior of caching any redirect.

Any thoughts/suggestions are welcome,

Thank you,

Eran

> Thanks,
> Marton
>


More information about the ffmpeg-devel mailing list