• Resolved econsorsn

    (@econsorsn)


    Hi,

    for quite some time the cache ttl for mp4 videos isn’t working anymore and we can’t figure out what’s the issue with this.

    We’ve alreay tryed to add custom headers for mp5 but nothing works. Also tryed the recommanded solution fromt his thread: https://www.ads-software.com/support/topic/can-not-get-video-to-cache/

    For some reason it’s not working.

    Can you help us out whit that issue?

    Thanks in advance
    Sebastian

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 16 total)
  • Hi Sebastian,

    mp4 resources are static files, so such files are not cached by cache plugin. Only dynamic resources like the main document are cached. But static resources can be cached by browser and in your case they are cached. You can check it if you request one of your .mp4 videos directly. https://easy-software.com/wp-content/uploads/dms_archive-v2.mp4. If you check the load of the videos at least twice you see a 304 header in browser dev console and this means that the video is loaded from local browser cache and not from the server.

    Btw. Your provider hasn’t enabled QUIC, so your server is running with HTTP/2 instead of HTTP/3

    Thread Starter econsorsn

    (@econsorsn)

    Hi,

    thanks for the reply and the tipp.

    Why is lighthouse then still asking for cache ttl for mp4?
    https://pagespeed.web.dev/report?utm_source=psi&utm_medium=redirect&url=https%3A%2F%2Feasy-software.com%2Fde%2F

    How can we fix the missing TLL?

    Thanks,
    Sebastian

    .mp4 resources are automatically cached by browser and are handled like images. PageSpeed expects an cache-control header, but seems to be missed.

    For testing add this code to your .htaccess. Location of this code doesn’t matter.

    <FilesMatch "\.(jpg|JPG|jpeg|webp|jpe?g|woff|woff2|png|css|js|gif|swf|ico|ttf|eot|ico|js|mp4|webm|svg|json)$">
        Header set Cache-Control "public,max-age=31536000"
    </FilesMatch>
    Thread Starter econsorsn

    (@econsorsn)

    We had this header integrated so far.:

    <FilesMatch ".+\.(mp4|m4v)$">
     Header set Cache-control "public, max-age=31536000"
    </FilesMatch>

    We’ve added your code right below in .htaccess but Google is still missing the TTL.

    Strange…. It seems PageSpeed doesn’t differentiate static sources with other static sources like almost modern browser does it. The difference of mp4 to other static sources is, that mp4 are always stored on users harddisk because of the size of mp4 to reduce bandwith it. Therefore mp4 doesn’t need any cache-control or expire header. They are always cached. Anyway I don’t know why PageSpeed has this strange behavior and if you ask Google for the same issue, you will not find any solution for it.

    Thread Starter econsorsn

    (@econsorsn)

    Yes, I know. Opening this thread was my last hope.

    Don’t worry about this issue. Your page has a lot of major issues you have to fix.

    Plugin Support qtwrk

    (@qtwrk)

    please provide the report number

    you can get it in toolbox -> report -> click “send to LiteSpeed”

    Thread Starter econsorsn

    (@econsorsn)

    Hi,

    the report number is: HWXOUOCX

    Regards,
    Sebastian

    @econsorsn

    I think I know what is wrong.

    Could you please change my code from above into this:

    <FilesMatch "\.(jpg|JPG|jpeg|webp|jpe?g|woff|woff2|png|css|js|gif|swf|ico|ttf|eot|ico|js|mp4|webm|svg|json)$">
        Header set Cache-Control "public,max-age=31536000"
        # This should always be set if there are static sources
        Header unset ETag
    </FilesMatch>
    • This reply was modified 2 years, 6 months ago by serpentdriver.
    Thread Starter econsorsn

    (@econsorsn)

    @serpentdriver Thanks.

    I’ve replaced the code snippet, cleard the cache and tested the site again.

    View post on imgur.com

    Unfortunately, still no cache TTL is output.

    Regards
    Sebastian

    I setuped a page with the same code like you for video and also used one of your video and it works and PageSpeed like it, so there must be any definitions in your .htaccess that prevents it.

    If possible would you post your .htaccess?

    Thread Starter econsorsn

    (@econsorsn)

    Unfortunately, this is not possible.

    Any tips for us on what to look for that could potentially block TLL?

    There are two lines where the mp4 TTL is currently set. Does this possibly interfere with each other?

    Yout code:

    <FilesMatch "\.(jpg|JPG|jpeg|webp|jpe?g|woff|woff2|png|css|js|gif|swf|ico|ttf|eot|ico|js|mp4|webm|svg|json)$">
        Header set Cache-Control "public,max-age=31536000"
        # This should always be set if there are static sources
        Header unset ETag
    </FilesMatch>

    and this, i guess from the litespeed plugin

    ExpiresByType video/ogg A31536000
    ExpiresByType audio/ogg A31536000
    ExpiresByType video/mp4 A31536000
    ExpiresByType video/webm A31536000

    There are two lines where the mp4 TTL is currently set. Does this possibly interfere with each other?

    No, it doesn’t. Expire is responsible for the overall lifetime. Cache-Control is for the current session.

    I have just checked your page. Did you remove the last change?

    Thread Starter econsorsn

    (@econsorsn)

    Hi, no it’s still there.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Chache TTL for mp4 not working’ is closed to new replies.