mod_expire ExpiresByType

Is it better to put “ExpiresActive On” and “ExpiresByType” statements in the .htaccess or in your section of your Apache vhost configuration? Advantage or disavantage of each?



Thanks for your thoughts,

David DeWitt

I was hoping someone had some thoughts on this or would it be better to put this question in a different forum?



Thanks,

David DeWitt

I think you'll find very few real Apache Gurus in the cs-cart forum. You might try one of the Apache user forums for a more technical response.

[quote name='tbirnseth' timestamp='1311705140' post='118299']

I think you'll find very few real Apache Gurus in the cs-cart forum. You might try one of the Apache user forums for a more technical response.

[/quote]

Since we have lots of people trying to get the best preformace from there sites I thought some user would have an idea about this. I will go and find some apache forums and see what kind of responces I get.



Thanks,

David DeWitt

[quote name='dsdewitt' timestamp='1311709510' post='118307']

Since we have lots of people trying to get the best preformace from there sites I thought some user would have an idea about this. I will go and find some apache forums and see what kind of responces I get.



Thanks,

David DeWitt

[/quote]



you will get marginally better performance by not using .htaccess files

in you will need to make sure you have the following set

#ignore, do not read htaccess files

AllowOverride None



If you are using CS-Cart SEO addon then then seo rewrite rules will need to go in virtual host:





RewriteEngine on

Some hostings require RewriteBase to be uncommented Example:

Your store url is http://www.yourcompany.com/store/cart

So “RewriteBase” should be: RewriteBase /store/cart

#RewriteBase /

RewriteCond %{REQUEST_FILENAME} !.(?:png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php?sef_rewrite=1 [L,QSA]





the following is for setting header expires:



ExpiresActive On

Set up caching on media files for 1 week



ExpiresDefault A604800

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



ExpiresByType application/x-javascript A604800

ExpiresByType text/css A604800



FileETag none



The following is complete example for virtual host settings in httpd.conf

It includes ignore the htaccess file, url redirect, SEO rewrite, mod deflate (gzip) of files, expires headers, and no ETags







DirectoryIndex index.html index.php

Order allow,deny

Allow from all

Options +FollowSymLinks -Indexes -MultiViews -Includes

AllowOverride None



RewriteEngine on

Some hostings require RewriteBase to be uncommented Example:

Your store url is http://www.yourcompany.com/store/cart

So “RewriteBase” should be: RewriteBase /store/cart

#RewriteBase /

redirect mystore.com mystore.net www.mystore.netwww.mystore.com

RewriteCond %{HTTP_HOST} !^www.mystore.(com|net) [NC]

RewriteCond %{HTTP_HOST} !^$

RewriteRule ^/?(.*) http://www.mystore.com/$1 [L,R=301,NE]



RewriteCond %{REQUEST_FILENAME} !.(?:png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php?sef_rewrite=1 [L,QSA]







SetOutputFilter DEFLATE


MSIE masquerades as Netscape, but it is fine

BrowserMatch \bMSIE !no-gzip !gzip-only-text/html


Don't compress images

SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary






Make sure proxies don't deliver the wrong content

Header append Vary User-Agent env=!dont-vary







ExpiresActive On

Set up caching on media files for 1 week



ExpiresDefault A604800

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



ExpiresByType application/x-javascript A604800

ExpiresByType text/css A604800



FileETag none







You will need to load module deflate for Apache deflate (gzip), you will find this in httpd.conf load modules section:

LoadModule deflate_module modules/mod_deflate.so