Tech Community Live: Windows edition
Jun 05 2024, 07:30 AM - 11:30 AM (PDT)
Microsoft Tech Community

Prevent Caching of Specific Files in IIS 10--Help with Code in web.config

Copper Contributor

I'm running a streaming server now, using nginx to ingest from OBS studio and write an .m3u8 and .ts files to IIS server directory. I've added MIME type .m3u8 to get it to work.

Initially I found that browser caching was preventing the stream from playing anything but the same 8-second segment. I was able to disable all caching with line 6 below from sample file I found online. However, I'd prefer not to disable ALL caching if possible.

I tried adding in line 3, 4 and 5 and changed the .jpg to my stream1.m3u8 file that I want to not be cached, but I got a 500 server error when I did that.

1

<configuration>

 

2

  ...

 

3

  <location path="myimage.jpg">

 

4

    <system.webServer>

 

5

      <staticContent>

 

6

        <clientCache cacheControlMode="DisableCache" />

 

7

      </staticContent>

 

8

    </system.webServer>

 

9

  </location>

 

10

</configuration>

There is another way supposedly to do this within IIS using the Output Caching menu and adding a rule to not cache specific files, but this does not work. It serves the stale video again. The only method that works so far, is the web.config edit disabling ALL caching (omitting lines 3,4,5).

Have I implemented either of these incorrectly?

 

M_A_Weiss_1-1698509994896.png

 

 

Is it possible to stop the caching of .m3u8 file and .ts files without disabling ALL caching?

1 Reply
Did you ever find a solution to this? I have exactly the same problem. Thanks.