This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
OctoberCMS provides a cool way to minify assets (CSS and JS)
Once minified and compressed into a single file, the assets URL will look like :
mysite.com/combine/45978640c0ac1o99f860cabeb8413e6
As there is no extension to the file, it is not GZIP compressed. Is there a way to fix this?
Here is my .htaccess for the GZIP compression:
<IfModule mod_deflate.c>
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/x-javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml \
text/text
</IfModule>
</IfModule>
Last updated
If you add the extension manually like this it would work.
<link href="{{ [
'assets/css/theme.css'
]|theme }}.css" rel="stylesheet">
and the same with .js files
Last updated
I'm having (or had) the same issue. Despite all my efforts, I could not enable DEFLATE compression, but ONLY for the JS output of the combiner. Is this a general problem or a problem of my setup? It seems the PaaS I'm using has a reverse proxy in front of the Apache webserver, which might have an effect or not.
However, I managed to solve the problem by handling the compression directly in CombineAssets.php with plain old PHP:
Index: modules/system/classes/CombineAssets.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- modules/system/classes/CombineAssets.php (revision )
+++ modules/system/classes/CombineAssets.php (revision )
@@ -178,6 +178,7 @@
$mime = ($cacheInfo['extension'] == 'css') ? 'text/css' : 'text/javascript';
header_remove();
+ if(!ob_start("ob_gzhandler")) ob_start();
$response = Response::make($contents);
$response->header('Content-Type', $mime);
Anything wrong with my solution? Well, if it is stupid but it works..
Last updated
The best solution so far is to add the following on top of your main index.php file. This will gzip your entire website, js and css components since they all go trough this index.php page.
if(!ob_start("ob_gzhandler")) ob_start();
It reduced the size of my website by 70% from 900KB to 623KB.
I attempted creating a plugin with settings but I was not able to execute ob_start within the plugin space. Any other ideas?
It would be nice to have this option instead of modifying the index.php file.
Last updated
Hello , If i used nginx server then what should i do.? How to set gzip code nginx server. thank you.
1-6 of 6