WordPress.org

Ready to get started?Download WordPress

Forums

How to GZIP my stylesheet and js using wp-super-cache (6 posts)

  1. Alex Cragg
    Member
    Posted 6 years ago #

    I've been taking steps to improve the speed of my blog, http://epicalex.com/ , one of which is the use of the wp-super-cache plugin.

    I've also been using the YSlow firefox plugin, that tells you why your site might be loading slowly. One of its complaints is that my stylesheets and javascript files are not gzipped, but gzipping is enabled in wp-super-cache.

    Is there anything I have to do differently to get them to be gzipped? or can I do it manually somehow, or am I trying to do this for no real reason?

    Thanks in advance,

    Alex

  2. benzwu
    Member
    Posted 6 years ago #

    it requires a whole different beast. try phpspeedy or phpspeedy wp plugin @ http://aciddrop.com/

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    I like this little hack for that sort of thing.

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP:accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME} !^.+\.gz$
    RewriteCond %{REQUEST_FILENAME}.gz -f
    RewriteRule ^(.+) $1.gz [L]
    </IfModule>

    This would need to be before the normal .htaccess rules in WordPress, or in a separate .htaccess file in your theme directory.

    Basically, if the browser doing the request says that gzipped files are okay, and there exists a gzipped version of a file, it will send that instead. So all you have to do for your css file is to make another copy of it, gzipped, with an extra .gz extension. Like "style.css.gz". Then that one will get sent instead of the original for browsers that can handle it.

    It'll work for JS files too. Use the 7Zip compressor to make a gzipped version of it, load it in the same directory as the original and voila.

    Note: You have to keep the original around too, for those cases where this won't work. Also, when you make changes, you'll need to manually recompress the new file.

  4. Alex Cragg
    Member
    Posted 6 years ago #

    So just to make sure I'm doing this right as this stuff is all new to me(I tried it and my jquery effects stopped working, but the gzipped version was served)...

    In my main .htaccess, I have this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond .... ALL THE NORMAL WP SUPER CACHE CONDITIONS AND RULES
    <IfModule mod_rewrite.c>
    NORMAL WORDPRESS CONDITIONS HERE -f and -d ETC
    </IfModule>
    </IfModule>
    # END WordPress

    Where do I put this new rule Otto? And do I include all of the IfModule part?

    Also, when I used the 7zip compressor, I just used the default settings, but when I looked at the script panel of firebug, all I could see was 2 or 3 weird symbols, like G@ for example. Is that how it should appear...I'm guessing not?

    Thanks again

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    You'd put the new code before all of that, outside the #BEGIN and #END stuff entirely. Never change anything inside that section, consider that to be WordPress's private domain.

    Or, like I said, you could put the rules in an .htaccess in the theme directory directly.

    I don't really use the 7zip compressor, so I don't know much about it. I just read that it was possible to make gzip's with it on Windows. I personally make gzips using gzip on a Linux box. You could use this instead, I suspect:
    http://gnuwin32.sourceforge.net/packages/gzip.htm

  6. beernews
    Member
    Posted 6 years ago #

    Complete noob to wordpress.org here though I have done a decent amount of research to get to this point. I'm trying to make the site as fast as possible. I was unable to get wp-super-cache to work (the directory doesn't get created) though wp-cache works so at least I have that much working.

    I'm wondering if it is possible to configure combine.php on top of wp-cache or whether I'd have to use one or the other.

Topic Closed

This topic has been closed to new replies.

About this Topic