0

my site is running IPB 3.1.4 and I want to pre-compress my .js files. I have ssh root access and need the command to gzip the js directory and the code for htaccess.

My htaccess:

Options -Indexes

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

<FilesMatch "\.(ico|flv|jpe?g|png|gif|js|css|swf)$">
ExpiresActive On
ExpiresDefault "access plus 1 month"
</FilesMatch>

FileETag none
user71793
  • 1
  • 1

3 Answers3

1

If you are running your own VPS or dedicated server, then mod_deflate for Apache can help you to solve this.

0

Might the bash script in an answer to this question help?

Paul
  • 779
0

I don't have the htaccess, but since I did that on Nginx some time ago, I can at least give you the bash script. I scans a directory (and its subdirectories) and gzip the listed filetypes. It also regenerates gzip when the source is more recent.

#! /bin/bash
# jve - 2011
# this script checks a list of directories for a list of extensions and
# generated gzipped versions of the files that are found
# if the modification date of a file is newer than its gzipped version
# then the gzip file is regenerated

#     specify a filetype like *.css or a filename like index.html
# leave one space between each entry
FILETYPES="*.css *.jpg *.jpeg *.gif *.png *.js *.html"

# specify a list of directories to check recursively
DIRECTORIES="/var/www/nginx_default/*"

for currentdir in $DIRECTORIES
do
   for extension in $FILETYPES
   do
      find $currentdir -iname $extension -exec bash -c 'PLAINFILE={};GZIPPEDFILE={}.gz; \
         if [ -e $GZIPPEDFILE ]; \
         then   if [ `stat --printf=%Y $PLAINFILE` -gt `stat --printf=%Y $GZIPPEDFILE` ]; \
                then    echo "$GZIPPEDFILE outdated, regenerating"; \
                        gzip -9 -f -c $PLAINFILE > $GZIPPEDFILE; \
                 fi; \
         else echo "$GZIPPEDFILE is missing, creating it"; \
              gzip -9 -c $PLAINFILE > $GZIPPEDFILE; \
         fi' \;
   done
done

the link to the original article is here: http://wiki.linuxwall.info/doku.php/en:ressources:dossiers:nginx:nginx_performance_tuning