179
GitHub - dc0d/cache-control: cache-control middleware
source link: https://github.com/dc0d/cache-control
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
cache-control
cache-control middleware adds ETag header (md5 of the content) and Cache-Control header
sample usage
Using chi router, we register this middleware before a http.FileServer
:
fs := http.Dir(`./assets`) assetServer := http.FileServer(fs) rt.Route("/assets/*", func(rt chi.Router) { rt.Use(cachecontrol.CacheControl( fs, cachecontrol.StripPrefix("/assets"))) rt.Get( "/*", http.StripPrefix("/assets", assetServer).ServeHTTP) })
- dirwatch can be used for watching directories of assets (next).
- more tests
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK