Youtube, FB, IG contents are more dynamic because of their varying URLs caused by CDNs. The URLs are the key used by Squid to identify cached objects. IMHO, an optimal solution is to hash the contents to let Cache search by content hash values rather than content URLs. However, how to know the hash value requested by users in advance?
BTW, "the YouTube URL can be parsed to find the id of the video. These seem to be constant for the same video of the same resolution. "
I've tried on this observation using Laptop and Smartphone to open the same YouTube clip:
- Laptop: https://www.youtube.com/watch?v=oAwGBYdvwW0
- Smartphone: https://www.youtube.com/oAwGBYdvwW0?si=qmdgeTLhUYobTXi6
- We can see the video ID "oAwGBYdvwW0"
Facebook to the same image:
- Laptop: https://scontent.fbkk6-2.fna.fbcdn.net/v/t39.30808-6/475548702_1142874757632916_6715193667665471540_n.jpg?_nc_cat=109&ccb=1-7&_nc_sid=127cfc&_nc_ohc=97bVWxJsE34Q7kNvgGXLIZG&_nc_zt=23&_nc_ht=scontent.fbkk6-2.fna&_nc_gid=A4HSUZOcURM3gh5kv_J0jUd&oh=00_AYCL-mz6AA3IVSH3ZZfKOFrqcJeT8NqjvSgC6VJYPJ8R5g&oe=67A756B0
- Smartphone (desktop mode): https://scontent.fbkk6-2.fna.fbcdn.net/v/t39.30808-6/475548702_1142874757632916_6715193667665471540_n.jpg?_nc_cat=109&ccb=1-7&_nc_sid=127cfc&_nc_ohc=97bVWxJsE34Q7kNvgGXLIZG&_nc_zt=23&_nc_ht=scontent.fbkk6-2.fna&_nc_gid=AxT6EmOD0b2GQ9OOKogzORK&oh=00_AYDAk_MK9VhJ4oyrHOLXz8HOmAmo4AeoHfjqxGjDW7rU8Q&oe=67A756B0
- Image ID is probably "475548702_1142874757632916_6715193667665471540_n.jpg" ซึ่งโชว์อยู๋บนชื่อ tab ใน web browser ด้วย
เพราะยังไงก็ตาม dynamic URLs ต้อง map ไปยัง the same resource object (many to one) อยู่แล้วโดยอาศัย Object ID นั่งเอง จึงต้อง parse object ID ออกมาให้ได้ก็จะ cache ได้ในที่สุด ส่วน one to many หมายถึง URL เดียวอาจ refer to different objects แต่ต้อง ณ ต่างเวลากันซึ่งเกิดจาก URL reuse ซึ่งก็เข้าข่าย object expiration ของ object เดิมก่อนที่ URL จะถูก reused ไปชี้ new object
ท้ายที่สุดเป็นเรื่องของการ implement Caching proxy ทำยังไงจึง parse Object ID to enable caching ส่วน cache replacement policy ยังมีประโยชน์เหมือนเดิม
https://wiki.squid-cache.org/ConfigExamples/DynamicContent/YouTube
https://wiki.squid-cache.org/ConfigExamples/DynamicContent/Coordinator