From e6fd79bad907c18e35fb2f99842b0ab62ed67114 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Thu, 26 Feb 2026 10:24:43 -0500 Subject: start caching html pages, lower request tree chaining --- src/public/img/background.webp | Bin 0 -> 12142 bytes src/public/img/headerLogo.png | Bin 672232 -> 112259 bytes src/public/img/headerLogo.webp | Bin 61450 -> 13540 bytes src/scss/_mixins.scss | 20 +++++++++++++------- src/scss/main.scss | 6 +++++- src/web/_views/bucket/main.php | 18 +++++++++--------- src/web/_views/head.php | 27 +++++++++++++++++++++++++-- src/web/lib/html.php | 8 ++++++++ 8 files changed, 60 insertions(+), 19 deletions(-) create mode 100644 src/public/img/background.webp create mode 100644 src/web/lib/html.php diff --git a/src/public/img/background.webp b/src/public/img/background.webp new file mode 100644 index 0000000..e5275e2 Binary files /dev/null and b/src/public/img/background.webp differ diff --git a/src/public/img/headerLogo.png b/src/public/img/headerLogo.png index c829aa2..b92ddaf 100644 Binary files a/src/public/img/headerLogo.png and b/src/public/img/headerLogo.png differ diff --git a/src/public/img/headerLogo.webp b/src/public/img/headerLogo.webp index 5596d1d..e92ca7e 100644 Binary files a/src/public/img/headerLogo.webp and b/src/public/img/headerLogo.webp differ diff --git a/src/scss/_mixins.scss b/src/scss/_mixins.scss index 0879b18..25eb0c1 100644 --- a/src/scss/_mixins.scss +++ b/src/scss/_mixins.scss @@ -65,13 +65,13 @@ @mixin font-face($name) { @font-face { font-family: $name; - src: url("../font/" + $name + ".eot"); - src: url("../font/" + $name + ".eot?#iefix") format("embedded-opentype"), - url("../font/" + $name + ".woff2") format("woff2"), - url("../font/" + $name + ".woff") format("woff"), - url("../font/" + $name + ".ttf") format("truetype"), - url("../font/" + $name + ".otf") format("opentype"), - url("../font/" + $name + ".svg#" + $name) format('svg'); + src: url("WEB_ROOTpublic/font/" + $name + ".eot"); + src: url("WEB_ROOTpublic/font/" + $name + ".eot?#iefix") format("embedded-opentype"), + url("WEB_ROOTpublic/font/" + $name + ".woff2") format("woff2"), + url("WEB_ROOTpublic/font/" + $name + ".woff") format("woff"), + url("WEB_ROOTpublic/font/" + $name + ".ttf") format("truetype"), + url("WEB_ROOTpublic/font/" + $name + ".otf") format("opentype"), + url("WEB_ROOTpublic/font/" + $name + ".svg#" + $name) format('svg'); font-weight: normal; font-style: normal; font-display: swap; @@ -89,3 +89,9 @@ -dt-display: table-cell; display: table-cell; } + +@mixin background-image($fallback, $sources...) { + background-image: $fallback; + background-image: -webkit-image-set(#{$sources}); + background-image: image-set(#{$sources}); +} diff --git a/src/scss/main.scss b/src/scss/main.scss index 362e6b9..f750dea 100644 --- a/src/scss/main.scss +++ b/src/scss/main.scss @@ -114,7 +114,11 @@ html { } body { - background-image: url("../img/background.png?ref=3"); + @include background-image( + url("WEB_ROOT/public/img/background.png?ref=4"), + url("WEB_ROOT/public/img/background.webp?ref=4") type("image/webp"), + url("WEB_ROOT/public/img/background.png?ref=4") type("image/png") + ); background-repeat: repeat; background-size: 512px; background-color: #181818; diff --git a/src/web/_views/bucket/main.php b/src/web/_views/bucket/main.php index aeb6cf3..b85c773 100644 --- a/src/web/_views/bucket/main.php +++ b/src/web/_views/bucket/main.php @@ -1,13 +1,13 @@ - view('head', $data); - if ($lightmode === 'true') { - echo $this->link_css('css/bucket_light.css'); - } else { - echo $this->link_css('css/bucket.css'); - } - ?> +view('head', $data); + if ($lightmode === 'true') { + echo embed_css_ext('css/bucket_light.css'); + } else { + echo embed_css_ext('css/bucket.css'); + } +?> diff --git a/src/web/_views/head.php b/src/web/_views/head.php index 1ca6954..8cd6f87 100644 --- a/src/web/_views/head.php +++ b/src/web/_views/head.php @@ -1,4 +1,19 @@ +req['app']; + $non_cached_apps = ['blog']; + + if (ENVIRONMENT == 'production' && !in_array($current_app, $non_cached_apps)) { + $cache_seconds = 300; + if ($current_app == 'bucket') { + $cache_seconds = 3600; + } + header("Cache-Control: public, max-age=$cache_seconds"); + header("Expires: " . gmdate('D, d M Y H:i:s', time() + $cache_seconds) . " UTC"); + header("Pragma: cache"); + } +?> @@ -21,10 +36,18 @@ "> "> + + " as="font" type="font/woff2" crossorigin> + " as="font" type="font/woff2" crossorigin> + + + " as="font" type="font/woff2" crossorigin> + req['app'] != 'bucket') - echo $this->link_css('css/main.css'); + if (ROUTER->req['app'] != 'bucket') { + echo embed_css_ext('css/main.css'); + } /* IE 4-7 Styles */ echo ie($this->embed_css('css/ie/ie.css')); diff --git a/src/web/lib/html.php b/src/web/lib/html.php new file mode 100644 index 0000000..9649bf4 --- /dev/null +++ b/src/web/lib/html.php @@ -0,0 +1,8 @@ +