Wowza Community

Is it possible to set different Cache-Control header for 200 and 404 request

Hi, we find out that our CDN provider Cloudflare will cache 404 responses for 5 minutes. So if someone asks for a .ts file that doesn’t exist yet, Wowza would response 404. And if these .ts files become available within this 5 minutes period, because CDN would response the 404 cached response. So the audiences in that zone would not be able to watch it. (A kind of DOS…)

So is it possible to response different HTTP headers for 200 response and 404 response? 200 response can be with a longer max-age header, while 404 can be no cache. Thank you.

Hello @Toby Lam

I believe you have a similar support ticket opened.

I will provide the latest response we have for this question, in hopes that it may help others with a similar question/issue.

You can edit/add a property to HTTPStreamer/Properties to control the Cache-Control header that is returned for HTTP streaming when a response in the 400s is returned

To change this for all http protocols you can use httpCacheControlStatus4xx then set value to no-cache
It would look something like this:

<Property>
    <Name>httpCacheControlStatus4xx</Name>
    <Value>no-cache</Value>
    <Type>String</Type>
</Property>

You could also use values that are documented here:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control

If you wanted to only send a response like that for HLS stream requests, you would use cupertinoCacheControlStatus4xx for the name.

Each application would need to be changed to contain the above to send the response you want for the 400s responses.

The 200s responses are handled by the playlist and chunk responses that I mentioned before.
So it would look something like this for playlist:

    <Property>
        <Name>cupertinoCacheControlPlaylist</Name>
        <Value>max-age=[number of seconds]</Value>
        <Type>String</Type>
    </Property>

Similarly for each chunk:

    <Property>
        <Name>cupertinoCacheControlMediaChunk</Name>
        <Value>max-age=[number of seconds]</Value>
        <Type>String</Type>
    </Property>