{ The .htaccess File

{ June 22nd, 2011 | By | Under: Web Development | Tags: , | No Comments »
.htaccess

Image by cocoate.com via Flickr

Been a long time since i posted!

I shall post with a small article about the htaccess file i used, I have been doing much research on web pageĀ optimizationĀ and i will share some of these bit by bit.

First the htaccess file!

#####################################################

# CONFIGURE media caching

#

# Header unset Expires

# Turn on Expires and set default expires to 3 days

ExpiresActive On

ExpiresDefault A259200

 

# Set up caching on media files for 1 month

<FilesMatch “\.(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$”>

ExpiresDefault A29030400

Header append Cache-Control “public”

</FilesMatch>

 

# Set up 2 Hour caching on commonly updated files

<FilesMatch “\.(xml|txt|html|js|css)$”>

ExpiresDefault A604800

Header append Cache-Control “private, must-revalidate”

</FilesMatch>

 

# Force no caching for dynamic files

<FilesMatch “\.(php|cgi|pl|htm)$”>

ExpiresDefault A0

Header set Cache-Control “no-store, no-cache, must-revalidate, max-age=0″

Header set Pragma “no-cache”

</FilesMatch>

#

#####################################################

<IfModule mod_deflate.c>

<FilesMatch “\.(js|css)$”>

SetOutputFilter DEFLATE

</FilesMatch>

</IfModule>

 

<IfModule mod_gzip.c>

mod_gzip_on Yes

mod_gzip_dechunk Yes

mod_gzip_keep_workfiles No

mod_gzip_can_negotiate Yes

mod_gzip_add_header_count Yes

mod_gzip_send_vary Yes

mod_gzip_command_version ‘/mod_gzip_status’

mod_gzip_min_http 1000

mod_gzip_minimum_file_size 300

mod_gzip_maximum_file_size 512000

mod_gzip_maximum_inmem_size 60000

mod_gzip_handle_methods GET POST

mod_gzip_temp_dir /tmp

mod_gzip_item_include file \.html$

mod_gzip_item_include file \.php$

mod_gzip_item_include file \.pl$

mod_gzip_item_include file \.rb$

mod_gzip_item_include file \.py$

mod_gzip_item_include file \.cgi$

mod_gzip_item_include file \.css$

mod_gzip_item_include file \.js$

mod_gzip_item_include mime ^application/javascript$

mod_gzip_item_include mime ^application/x-javascript$

mod_gzip_item_include mime ^text/.*

mod_gzip_item_include mime ^httpd/unix-directory$

mod_gzip_item_include handler ^cgi-script$

mod_gzip_item_include handler ^server-status$

mod_gzip_item_include handler ^server-info$

mod_gzip_item_include handler ^application/x-httpd-php

mod_gzip_item_exclude mime ^image/.*

</ifModule>

 

<ifModule mod_headers.c>

Header unset ETag

</ifModule>

FileETag None


The first block will set http caching on. The 2nd block will turn on gzipping and the last 2 lines will take away etags. I will try to explain the exact meaning of those stuff in time!

No related posts.

No Comments »

Leave a Reply

  • Please leave these two fields as-is:

    Protected by Invisible Defender. Showed 403 to 5,293 bad guys.