Apache Settings

Introduction

  • For Apache settings related to the deployment of a BigFish eCommerce implementation please refer to the specific Deployment guides

BigFish Admin Module: Setup Friendly URL Access:

  • These changes will mean that the BigFish Admin Module can be accessed via a link such as http://www.yourdomain.com/osafe-admin/control/main without the need to specific a port number
  • Modify the vhosts file as follows:

in <VirtualHost *:443> add:


RewriteCond %{REQUEST_URI} !^/osafe-admin/.*$    
RewriteCond %{REQUEST_URI} !^/osafe_admin_theme/.*$
RewriteCond %{REQUEST_URI} !^/osafe_admin_theme/.*$

and


ProxyPass /osafe-admin ajp://localhost:8007/osafe-admin
ProxyPassReverse /osafe-admin ajp://localhost:8007/osafe-admin
ProxyPass /osafe_admin_theme ajp://localhost:8007/osafe_admin_theme
ProxyPassReverse /osafe_admin_theme ajp://localhost:8007/osafe_admin_theme  

Controlling Browser Caching

  • To control browser caching in Apache the mod_expires and mod_headers modules must be turned on. Most installations and builds of Apache include these modules since they are pretty essential. To verify this is the case, make sure that they are turned on by opening the httpd.conf file and making sure the following two lines do not have a # sign in front of them.
    • Code Sample:

LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so

  • When these modules are loaded and working, the Apache directives can control how browsers cache everything from pages to images across the whole site or in a specific directory. These directives will allow you to have either general or fine grained control over how a browser caches each file/type on your site.

Examining Your HTTP Headers

  • Determine if your site is taking advantage of browser caching, examine the HTTP headers on any given server response, be it a whole page or a single file. A common HTTP header response will look something like this:
    • Code Sample:

HTTP/1.1 200 OK
Date: Sun, 19 Feb 2006 16:42:05 GMT
Server: Apache/2.0.55 (Unix) DAV/2 PHP/5.1.1
Last-Modified: Sun, 08 Jan 2006 16:17:25 GMT
ETag: "73049-defc-37c52f40"
Accept-Ranges: bytes
Content-Length: 57084
Cache-Control: max-age=7200
Expires: Sun, 19 Feb 2006 18:42:05 GMT
Connection: close
Content-Type: image/png

  • What to look for in the header are the "Cache-Control" and "Expires" fields. These fields control how long the browser will cache this media or page asset from your server. Having a low value like "1" in "Cache-Control" can be just as bad as no value at all.
  • Tools to Examine Http Headers:

Setting Apache ‘Directive’ to control Browser Caching

  • The directives here can be placed into the <Directory> directive of your virtual host in httpd.conf or it can be placed loosely in a .htaccess file in the root of your website:
    • Code Sample:

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 1 seconds"
  ExpiresByType image/gif "access plus 120 minutes"
  ExpiresByType image/jpeg "access plus 120 minutes"
  ExpiresByType image/png "access plus 120 minutes"
  ExpiresByType text/css "access plus 60 minutes"
  ExpiresByType text/javascript "access plus 60 minutes"
  ExpiresByType application/javascript "access plus 60 minutes"
  ExpiresByType application/x-javascript "access plus 60 minutes"
  ExpiresByType text/xml "access plus 60 minutes"
</IfModule>

  • This directive can be modified to suite your tastes or it can just be used "as is" for most users. This directive will do the following:
    • Set the default expiration of content in the browser cache to 1 second past the time of accessing that content. This is good for setting a catchall or default if you fail to explicitly define a content type in the following directives.
    • Set the expiration of text/html pages to 1 second. This is a good setting since technically most html pages are small and page content should always be fresh.
    • Set the expiration of standard images like GIFF, JPEG, and PNG to 2 hours.
    • Set the expiration of CSS and JavaScript to 1 hour.
    • Set the expiration of XML files to 1 hour.
  • Full documentation of the expires directive can be found on Apache's website along with different syntax formats than the ones used here.

Compressing Web Pages

  • To control browser compression in Apache the mod_deflate module must be turned on. Most installations and builds of Apache include this. To verify this is the case, make sure it is turned on by opening the httpd.conf file and making sure the following line does not have a # sign in front.
    • Code Sample:

LoadModule deflate_module modules/mod_deflate.so

  • The mod_deflate module allows the Apache web service to compress files and deliver them to clients (browsers) that can handle them. With mod_deflate you can compress HTML, text or XML files by up to 70% of their original sizes. Thus, saving you server traffic and speeding up page loads.
  • The module is configured in the httpd.conf by adding the following lines at the very bottom of the file, making sure they are separated from any other configurations.
    • Code Sample:

<IfModule mod_deflate.c>
  SetOutputFilter DEFLATE
#Set compression level to max (9)
  DeflateCompressionLevel 9
#Don't Compress images (they're already compressed)
  SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
  SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
</IfModule>


    • Code Sample:

AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

Back to Top

Built by Solveda