Skip to content

Commit

Permalink
origin: cache .jpg file
Browse files Browse the repository at this point in the history
  • Loading branch information
dev committed Dec 27, 2023
1 parent bff509e commit 2c06418
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion origin/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/skerkour/cloudflare-for-speed-and-security/origin
go 1.21.5

require (
github.com/bloom42/stdx v0.0.0-20231226155351-fa0ff3a7e645
github.com/bloom42/stdx v0.0.0-20231227083324-cfdd3308c7d1
github.com/go-chi/chi/v5 v5.0.11
golang.org/x/crypto v0.17.0
)
Expand Down
4 changes: 4 additions & 0 deletions origin/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
github.com/bloom42/stdx v0.0.0-20231226155351-fa0ff3a7e645 h1:1QfapnvgM6/P3MPKQftTncM6vz6TN6H3xNSR3C/r9RU=
github.com/bloom42/stdx v0.0.0-20231226155351-fa0ff3a7e645/go.mod h1:EZT4MIjPfxv03r8l4AWIuoaUqJarn3x6B1JxF3rkDGA=
github.com/bloom42/stdx v0.0.0-20231227081440-b7c9e15ebc50 h1:Xe5zqrudRVneuubGEkd+V/PnToCI+N/xdLGWJ9FAMIQ=
github.com/bloom42/stdx v0.0.0-20231227081440-b7c9e15ebc50/go.mod h1:EZT4MIjPfxv03r8l4AWIuoaUqJarn3x6B1JxF3rkDGA=
github.com/bloom42/stdx v0.0.0-20231227083324-cfdd3308c7d1 h1:RER3cgZ39BufN0N5ETVZ7sTeeQYrPH5THYFImgZX+fs=
github.com/bloom42/stdx v0.0.0-20231227083324-cfdd3308c7d1/go.mod h1:EZT4MIjPfxv03r8l4AWIuoaUqJarn3x6B1JxF3rkDGA=
github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA=
github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
Expand Down
7 changes: 6 additions & 1 deletion origin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ func loadRouter() (router chi.Router, err error) {

router.Get("/", IndexHandler)

webappHandler, err := httpx.WebappHandler(assetsFS, "404.html", http.StatusNotFound)
webappHandlerConfig := httpx.WebappHandlerConfig{
FileNotFound: "404.html",
StatusNotFound: http.StatusNotFound,
ImmutableFilesExtensions: []string{".js", ".css", ".jpg"},
}
webappHandler, err := httpx.WebappHandler(assetsFS, &webappHandlerConfig)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion origin/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
<p>Dynamic files:</p>
<ul>
<li><a href="/100k.bin">/100k.bin</a></li>
<li><a href="/100k.jpg">/100k.jpg</a></li>
</ul>
<hr />

<p>Cached files:</p>
<ul>
<li><a href="/100k.css">/100k.css</a></li>
<li><a href="/100k.js">/100k.js</a></li>
<li><a href="/100k.jpg">/100k.jpg</a></li>
</ul>

</body>
Expand Down

0 comments on commit 2c06418

Please sign in to comment.