"Cache-busting" for static files

This commit is contained in:
Cadence Ember 2022-10-30 23:51:15 +13:00
parent 8b200d621a
commit d3c5498d47
Signed by untrusted user: cadence
GPG key ID: BC1C2C61CF521B17
4 changed files with 14 additions and 11 deletions

View file

@ -8,6 +8,7 @@
"config.rkt" "config.rkt"
"data.rkt" "data.rkt"
"niwa-data.rkt" "niwa-data.rkt"
"static-data.rkt"
"pure-utils.rkt" "pure-utils.rkt"
"xexpr-utils.rkt" "xexpr-utils.rkt"
"url-utils.rkt") "url-utils.rkt")
@ -37,7 +38,7 @@
`(footer (@ (class "custom-footer")) `(footer (@ (class "custom-footer"))
(div (@ (class ,(if source-url "custom-footer__cols" "internal-footer"))) (div (@ (class ,(if source-url "custom-footer__cols" "internal-footer")))
(div (p (div (p
(img (@ (class "my-logo") (src "/static/breezewiki.svg")))) (img (@ (class "my-logo") (src ,(get-static-url "breezewiki.svg")))))
(p (p
(a (@ (href "https://gitdab.com/cadence/breezewiki")) (a (@ (href "https://gitdab.com/cadence/breezewiki"))
,(format "~a source code" (config-get 'application_name)))) ,(format "~a source code" (config-get 'application_name))))
@ -127,14 +128,13 @@
,@(map (λ (url) ,@(map (λ (url)
`(link (@ (rel "stylesheet") (type "text/css") (href ,url)))) `(link (@ (rel "stylesheet") (type "text/css") (href ,url))))
(required-styles (format "https://~a.fandom.com" wikiname))) (required-styles (format "https://~a.fandom.com" wikiname)))
(link (@ (rel "stylesheet") (type "text/css") (href "/static/main.css"))) (link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
(script "const BWData = " (script "const BWData = "
,(jsexpr->string (hasheq 'wikiname wikiname ,(jsexpr->string (hasheq 'wikiname wikiname
'strict_proxy (config-true? 'strict_proxy)))) 'strict_proxy (config-true? 'strict_proxy))))
,(if (config-true? 'feature_search_suggestions) ,(if (config-true? 'feature_search_suggestions)
'(script (@ (type "module") (src "/static/search-suggestions.js"))) `(script (@ (type "module") (src ,(get-static-url "search-suggestions.js"))))
"")) "")
(body (@ (class ,body-class))
(div (@ (class "main-container")) (div (@ (class "main-container"))
(div (@ (class "fandom-community-header__background tileHorizontally header"))) (div (@ (class "fandom-community-header__background tileHorizontally header")))
(div (@ (class "page")) (div (@ (class "page"))

View file

@ -49,7 +49,7 @@
"Icaruspedia" "Icaruspedia"
"https://www.kidicaruswiki.org/wiki/Main_Page" "https://www.kidicaruswiki.org/wiki/Main_Page"
"/images/logos/icaruspedia.png" "/images/logos/icaruspedia.png"
"Icaruspedia is the Kid Icarus wiki that keeps flying to new heights. After going independent on January 8, 2012, Icaruspedia has worked to become the largest and most trusted independent source of Kid Icarus information. Just like Pit, they\"ll keep on fighting until the job is done.") "Icaruspedia is the Kid Icarus wiki that keeps flying to new heights. After going independent on January 8, 2012, Icaruspedia has worked to become the largest and most trusted independent source of Kid Icarus information. Just like Pit, they'll keep on fighting until the job is done.")
(("splatoon" "uk-splatoon" "splatoon3" "splatoon2") (("splatoon" "uk-splatoon" "splatoon3" "splatoon2")
"Inkipedia" "Inkipedia"
"https://splatoonwiki.org/wiki/Main_Page" "https://splatoonwiki.org/wiki/Main_Page"
@ -145,7 +145,7 @@
"xexpr-utils.rkt") "xexpr-utils.rkt")
(define r (get "https://www.niwanetwork.org/members/")) (define r (get "https://www.niwanetwork.org/members/"))
(define x (html->xexp (bytes->string/utf-8 (response-body r)))) (define x (html->xexp (bytes->string/utf-8 (response-body r))))
(define english ((query-selector (λ (e a c) (println a) (equal? (get-attribute 'id a) "content1")) x))) (define english ((query-selector (λ (e a c) (equal? (get-attribute 'id a) "content1")) x)))
(define gen (query-selector (λ (e a c) (has-class? "member" a)) english)) (define gen (query-selector (λ (e a c) (has-class? "member" a)) english))
(for/list ([item (in-producer gen #f)]) (for/list ([item (in-producer gen #f)])
(define links (query-selector (λ (e a c) (eq? e 'a)) item)) (define links (query-selector (λ (e a c) (eq? e 'a)) item))

View file

@ -4,6 +4,7 @@
html-writing html-writing
web-server/http web-server/http
"application-globals.rkt" "application-globals.rkt"
"static-data.rkt"
"url-utils.rkt" "url-utils.rkt"
"xexpr-utils.rkt" "xexpr-utils.rkt"
"config.rkt") "config.rkt")
@ -62,9 +63,9 @@
(head (head
(meta (@ (name "viewport") (content "width=device-width, initial-scale=1"))) (meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
(title "About | BreezeWiki") (title "About | BreezeWiki")
(link (@ (rel "stylesheet") (type "text/css") (href "/static/internal.css"))) (link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "internal.css"))))
(link (@ (rel "stylesheet") (type "text/css") (href "/static/main.css"))) (link (@ (rel "stylesheet") (type "text/css") (href ,(get-static-url "main.css"))))
(link (@ (rel "icon") (href "/static/breezewiki-icon.svg")))) (link (@ (rel "icon") (href ,(get-static-url "breezewiki-icon.svg")))))
(body (@ (class "skin-fandomdesktop theme-fandomdesktop-light internal")) (body (@ (class "skin-fandomdesktop theme-fandomdesktop-light internal"))
(div (@ (class "main-container")) (div (@ (class "main-container"))
(div (@ (class "fandom-community-header__background tileBoth header"))) (div (@ (class "fandom-community-header__background tileBoth header")))

View file

@ -64,5 +64,7 @@
((files:make ((files:make
#:url->path (lambda (u) ((make-url->path path-static) u)) #:url->path (lambda (u) ((make-url->path path-static) u))
#:path->mime-type (lambda (u) (ext->mime-type (path-get-extension u))) #:path->mime-type (lambda (u) (ext->mime-type (path-get-extension u)))
#:cache-no-cache (config-true? 'debug) #;"browser applies heuristics if unset") #:cache-no-cache (config-true? 'debug)
#:cache-immutable (not (config-true? 'debug))
#:cache-max-age (if (config-true? 'debug) #f 604800))
conn new-req)) conn new-req))