• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Compression

Jeff Fuqua

Well-known member
#1
I'm trying to find ways to speed up my forum and saw on Google Speed Test that compression of various files was recommended.

One of those files was xenforo. js, tapatalk.js and a few others.

Since this is a bit beyond my skills, is a 142.7KiB savings worth saving?

It said the following:
"To enable compression, configure your web server to set the Content-Encoding header to gzip format for all compressible resources."

Is this wise to do? Any ideas how this is accomplished? Thanks.
 

robdog

Well-known member
#3
All the JS files that XenForo uses are compressed. However, I think if you are in debug mode, it will use the uncompressed versions of the JS files.

But to enable content encoding that you are talking about, add this to your htaccess file:
Code:
################################################################################
# START: MOD_EXPIRES
################################################################################
# Turn MOD_EXPIRES On
ExpiresActive On
 
# Set Images to Expire After a Month
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
 
# Set CSS/JS to Expire After a Month
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
 
# Set Flash to Expire After a Month
#ExpiresByType application/x-shockwave-flash "access plus 1 month"
 
# Set XML to Expire After a Week
ExpiresByType text/xml "access plus 1 week"
################################################################################
# END: MOD_EXPIRES
################################################################################
Of course you don't need all the comments, haha. BUT make sure you have mod_expires enabled through apache! Or you server will go BOOM! Oh and I commented out flash because I had some weird functionality enabling it.
 

Chris D

XenForo developer
Staff member
#5
When I stop being so busy with real life stuff, Jeff, I will help you to enable some sort of caching. What kind of caching we can enable depends on what your shared host allows us to use, but at the very least we should be able to get a bit of a performance boost from doing a file based back-end cache.

They might even have APC or memcache available, in which case that will be even better.
 

DBA

Well-known member
#7
All the JS files that XenForo uses are compressed. However, I think if you are in debug mode, it will use the uncompressed versions of the JS files.

But to enable content encoding that you are talking about, add this to your htaccess file:
Code:
################################################################################
# START: MOD_EXPIRES
################################################################################
# Turn MOD_EXPIRES On
ExpiresActive On
 
# Set Images to Expire After a Month
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
 
# Set CSS/JS to Expire After a Month
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
 
# Set Flash to Expire After a Month
#ExpiresByType application/x-shockwave-flash "access plus 1 month"
 
# Set XML to Expire After a Week
ExpiresByType text/xml "access plus 1 week"
################################################################################
# END: MOD_EXPIRES
################################################################################
Of course you don't need all the comments, haha. BUT make sure you have mod_expires enabled through apache! Or you server will go BOOM! Oh and I commented out flash because I had some weird functionality enabling it.
The above code sets the cache, you'll want something like the below code to compress (gzip) your files.

Code:
#SetOutputFilter DEFLATE
AddOutputFilter DEFLATE xhtml html htm php css js xml xsl txt plain javascript x-javascript ico