kaltura / nginx-vod-module

NGINX-based MP4 Repackager
GNU Affero General Public License v3.0
1.99k stars 439 forks source link

Mapped mode, how to clear json cache ? #1529

Open nvtienlg opened 3 months ago

nvtienlg commented 3 months ago

We are testing this module with mapped mode. Everything is working fine, however we don't know how to clear json cache to refetch it

  1. User requests {videoId}/master.m3u8
  2. Module calls to api backend api/json/{videoId}
  3. Api responses the json (include 360p and 480p)
  4. Module parses and caches it
  5. New 720p and 1080p come later (due to long transcoding), api backend already updated

How to force the Module to call api to refresh the json cache for given {videoId} ? We can set expiration for vod_mapping_cache, but that affects all videos, lets say calling to api is costly

Hope you understand the case. Thank you very much for great module

erankor commented 3 months ago

There is no support for cache invalidation, mainly because it won't help when there's a CDN in front of this module. What you can do instead is make a change to the URL - assuming you have some API that generates the master.m3u8 URL to the player, you can make a change there, the module will "see" a new URL, and will perform the mapping request again. For example, initially you return http://yourdomain/path/version/1/master.m3u8, after the transcoding is finished, you return http://yourdomain/path/version/2/master.m3u8.

nvtienlg commented 3 months ago

Thank you very much, got your point. What we done, base on your suggestion:

With that config seem we can update master playlist while keep using cache for media segments