skilld-labs / docker-php

Drupal 9 and 10 on PHP 8/7 dev containers
13 stars 16 forks source link

Unit config for .br files delivery instead of .css/.js #91

Open andypost opened 1 year ago

andypost commented 1 year ago

Follow-up to https://github.com/skilld-labs/docker-php/pull/90

Probably it needs extra match rule to test url rewrite for .br files for js/css assets

Docs https://unit.nginx.org/configuration/#static-files

Refs

andypost commented 1 year ago

Apache 2 config additions from https://www.drupal.org/project/drupal/issues/3184242

+    # Serve brotli compressed CSS files if they exist and the client accepts brotli.
+    RewriteCond %{HTTP:Accept-encoding} br
+    RewriteCond %{REQUEST_FILENAME}\.br -s
+    RewriteRule ^(.*css_[a-zA-Z0-9-_]+)\.css$ $1\.css\.br [QSA]
...
+    # Serve brotli compressed JS files if they exist and the client accepts brotli.
+    RewriteCond %{HTTP:Accept-encoding} br
+    RewriteCond %{REQUEST_FILENAME}\.br -s
+    RewriteRule ^(.*js_[a-zA-Z0-9-_]+)\.js$ $1\.js\.br [QSA]
...
+    RewriteRule \.css\.br$ - [T=text/css,E=no-gzip:1,E=no-brotli:1]
+    RewriteRule \.js\.br$ - [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
...
+    <FilesMatch "(\.js\.br\|\.css\.br)$">
+      # Serve correct encoding type.
+      Header set Content-Encoding br
+      # Force proxies to cache compressed & non-compressed css/js files separately.
+      Header append Vary Accept-Encoding
+    </FilesMatch>
andypost commented 1 year ago

Nginx already has it https://github.com/skilld-labs/skilld-docker-nginx/commit/7d769dd84ea82baa1919d84eea5a6e2e4b0418a1

andypost commented 11 months ago

We also should add static delivery for .well-known

andypost commented 4 months ago

also it needs to skip logging for images https://unit.nginx.org/news/2024/unit-1.32.0-released/#conditional-access-logging

andypost commented 4 months ago

Gzip commited https://github.com/skilld-labs/docker-php/commit/df6bfe538e447a043e421c04a122230a74a2b4b4