mirror of https://github.com/Xhofe/alist
				
				
				
			feat: cache static files (#2715)
							parent
							
								
									6f4b1ba4b3
								
							
						
					
					
						commit
						e58ca686e3
					
				|  | @ -65,6 +65,13 @@ func UpdateIndex() { | |||
| func Static(r *gin.Engine) { | ||||
| 	InitIndex() | ||||
| 	folders := []string{"assets", "images", "streamer"} | ||||
| 	r.Use(func(c *gin.Context) { | ||||
| 		for i := range folders { | ||||
| 			if strings.HasPrefix(c.Request.RequestURI, fmt.Sprintf("/%s/", folders[i])) { | ||||
| 				c.Header("Cache-Control", "max-age=86400") | ||||
| 			} | ||||
| 		} | ||||
| 	}) | ||||
| 	for i, folder := range folders { | ||||
| 		folder = "dist/" + folder | ||||
| 		sub, err := fs.Sub(public.Public, folder) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 BoYanZh
						BoYanZh