Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Increase cache duration for static files

Gabe Kangasff3276f11502
diff --git a/utils/utils.go b/utils/utils.go
index 8cd5448d70..bce2b3660d 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -165,23 +165,28 @@ func RenderPageContentMarkdown(raw string) string {
// GetCacheDurationSecondsForPath will return the number of seconds to cache an item.
func GetCacheDurationSecondsForPath(filePath string) int {
- if path.Base(filePath) == "thumbnail.jpg" {
+ filename := path.Base(filePath)
+ fileExtension := path.Ext(filePath)
+
+ if filename == "thumbnail.jpg" {
// Thumbnails re-generate during live
return 20
- } else if path.Ext(filePath) == ".js" || path.Ext(filePath) == ".css" {
+ } else if fileExtension == ".js" || fileExtension == ".css" {
// Cache javascript & CSS
- return 60
- } else if path.Ext(filePath) == ".ts" {
+ return 60 * 10
+ } else if fileExtension == ".ts" {
// Cache video segments as long as you want. They can't change.
// This matters most for local hosting of segments for recordings
// and not for live or 3rd party storage.
return 31557600
- } else if path.Ext(filePath) == ".m3u8" {
+ } else if fileExtension == ".m3u8" {
return 0
+ } else if fileExtension == ".jpg" || fileExtension == ".png" || fileExtension == ".gif" {
+ return 60 * 60 * 24
}
// Default cache length in seconds
- return 30
+ return 60 * 10
}
func IsValidUrl(urlToTest string) bool {