As it is right now, XenForo does deliver CSS through
This does work just fine, gives a lot of flexibility and the generated CSS can be cached efficiently by browsers.
However, doing it this way does require some PHP processing for each CSS call (there are typically 2 calls per page).
Also webservers will perform compression on every request.
While it is possible to setup a reverse proxy in front of
If CSS was stored as files, PHP processing (and compression if storing pre-compressed files and the webserver is configured to support that) could be avoided.
This was already suggested several years ago but rejected due to the dynamic nature of CSS URLs.
It would be nice if this idea could be given a second thought as I think it should be possible without much hassle:
Also this approach should be easy enough so it could benefit a lot of customers.
We are using this approach in production and it does seem to work just fine
css.php
.This does work just fine, gives a lot of flexibility and the generated CSS can be cached efficiently by browsers.
However, doing it this way does require some PHP processing for each CSS call (there are typically 2 calls per page).
Also webservers will perform compression on every request.
While it is possible to setup a reverse proxy in front of
css.php
to avoid PHP processing and recompressing for every request, this is rather complicated and not smth. a lot of customers could use (due to shared hosting, etc.)If CSS was stored as files, PHP processing (and compression if storing pre-compressed files and the webserver is configured to support that) could be avoided.
This was already suggested several years ago but rejected due to the dynamic nature of CSS URLs.
It would be nice if this idea could be given a second thought as I think it should be possible without much hassle:
- Just before delivering the final CSS to the browser though
css.php
, write the CSS to a file (ideally uncompressed, compressed with gzip and compressed with brotli if available) withindata
. - Change the HTML to always point to those files
- Have webserver rewrite rules in place to rewrite those requests to
css.php
in case the file does not exist - Add code to cleanup the generated files when CSS changes
Also this approach should be easy enough so it could benefit a lot of customers.
We are using this approach in production and it does seem to work just fine
Upvote
22