Magento aicache Stock Configuration

#########################################################################################################
# aiCache Configuration file template for RightScale
#########################################################################################################
#
server # DON'T REMOVE OR MODIFY THIS LINE
#
server_ip *                      # DEFAULT: we listen on all IPs/NICs defined on this host
server_port 80                   # DEFAULT: we run on default HTTP port 80

if_name eth0                     # MUST POINT TO VALID Interface name that you used to obtain the license

username aicache                 # Will run as this user, must be a valid user
groupname aicache                # Will run as this group, must be a valid group


logdirectory /var/log/aicache    # Log directory: access, error, stats, snmp.stat go there
stay_up_on_write_error           # When set, server will continue to service requests even when it runs 
                                 # out of space in log partition (directory).
drop_user_agent                  # Do not log user-agent information
log_healthcheck                  # Will log health check requests
logstats                         # Log global statistics
max_log_file_size 100000000      # Auto-rotate logs when it grows above 100 Mb


maxkeepalivereq 20               # Max # of keep-alive requests per client keep-alive connection
maxkeepalivetime 10              # Max lifespan of client keep-alive connection, seconds
maxclientidletime 4              # Max idle time of client keep-alive connection, seconds
maxosidletime 4                  # Origin Server connection max idle time

snmp_stat_interval 4             # SNMP stats refresh interval, seconds

max_os_ka_conn 2                 # Max number of origin server keep-alive connections, per origin server
max_os_ka_req 20                 # Max number of origin server requests per os keep-alive connection

# Alerts
alert_req_sec_max 2500           # Max number of requests per second, more will generate alert
alert_req_sec_min 0              # Min number of requests per second, less will generate alert
alert_bad_resp_sec 2             # Max bad responses (404, 500, etc...) from origin servers per second
alert_os_rt 200                  # Alert on origin response time (miliseconds) 

alert_dir /usr/local/aicache/alerts # Required for rightscale alerts
alert_email root@localhost          # Requered for rightscale alerts


# Uncomment following lines if you want to use aiCache to block DDOS attack
#clip_throttle                   # Enable clip throttle
#block_ip_interval 10
#block_ip_max_req 100
#silent_block_ip


#########################################################################################################
# Website
#########################################################################################################
#
website  # DON'T REMOVE OR MODIFY THIS LINE
#

hostname magentoshop.domain.com

min_gzip_size 4000               # Will compress compressible responses over 4000 bytes in size
fallback                         # Will fall back to prev cached response if new one can not be obtained
logstats                         # Will log basic website stats to a dedicated stats log file

healthcheck /test.html HTTP 5 4  # Will request /test.html every 5 seconds, match response to "HTTP", timeout 4 seconds

forward_os_cache_headers         # Pass on cache headers, so clients don't cache what shouldn't be cached

#########################################################################################################
# HTTP Headers. Do not modify without a very good reason.
#########################################################################################################
httpheaderder Connection keep-alive
httpheader Accept */*
httpheader Accept-Encoding gzip

#########################################################################################################
# Patterns: this is what sets up Time-to-Live (caching rules)
#########################################################################################################
# Early warning cookie, once we enter into user personal stuff (cart, comparisons, log in)
0ttl_url /catalog/product_compare
0ttl_url /checkout
0ttl_url /customer/account

pattern .ico  simple 7d no_log   # cache for a week, do not log in acces log file
pattern .js   simple 7d no_log   # cache for a week, do not log in acces log file
pattern .css  simple 7d no_log   # cache for a week, do not log in acces log file
pattern .jpg  simple 7d no_log   # cache for a week, do not log in acces log file
pattern .gif  simple 7d no_log   # cache for a week, do not log in acces log file
pattern .png  simple 7d no_log   # cache for a week, do not log in acces log file
pattern .woff simple 7d no_log   # cache for a week, do not log in acces log file

pattern ^/index.php/admin regexp 0 # admin pages not cacheable
pattern ^/checkout regexp 0                # checkout module pages not cacheable
pattern ^/customer regexp 0 # customer module pages not cacheable
pattern ^/catalog/product_compare regexp 0 # product compare feature

pattern ^/content regexp 30m # content pages (articles)

# All other content is cached for 30 minutes unless it carries some specific cookies
pattern / simple 30m
0ttl_cookie CUSTOMER               # Will have this once a visitor is logged in
0ttl_cookie CART                   # Will have this once a visitor has started adding things to the cart
0ttl_cookie NEWMESSAGE             # Notifications to user (i.e. product inserted in cart)
0ttl_cookie COMPARE                # Will have this once a visitor has started comparing products
0ttl_cookie nocache                # Magento provides this hint (in some cases)
0ttl_cookie aicache0ttlcookie      # If the user has started using any of the personalized functions

#########################################################################################################
# Origins. At least one must be defined
#########################################################################################################

origin 192.168.1.1 80


The most important bits here are:

forward_os_cache_headers           # Pass on cache headers, so clients don't cache what shouldn't be cached

This forwards Magento generated cache headers onto the client. These headers avoid the user browser to cache pages which later on may be updated (i.e. as the user adds items into the cart)

0ttl_url /catalog/product_compare
0ttl_url /checkout
0ttl_url /customer/account

When the user first visits any of the previous URLs, a cookie is forward to his browser. Later on we check for such cookie in the pattern section

pattern .ico  simple 7d no_log   # cache for a week, do not log in acces log file
pattern .js   simple 7d no_log   # cache for a week, do not log in acces log file
pattern .css  simple 7d no_log   # cache for a week, do not log in acces log file
pattern .jpg  simple 7d no_log   # cache for a week, do not log in acces log file
pattern .gif  simple 7d no_log   # cache for a week, do not log in acces log file
pattern .png  simple 7d no_log   # cache for a week, do not log in acces log file
pattern .woff simple 7d no_log   # cache for a week, do not log in acces log file

These patterns correspond to easily cacheable content (media, JavaScript, etc). These make the bulk of the requests, thus we check for them first.

pattern ^/index.php/admin regexp 0 # admin pages not cacheable
pattern ^/checkout regexp 0 # checkout module pages not cacheable
pattern ^/customer regexp 0 # customer module pages not cacheable
pattern ^/catalog/product_compare regexp 0 # product compare feature

These correspond to site areas which are not cacheable at all (admin dashboard, checkout process, product comparison features, etc.)

pattern ^/content regexp 30m # content pages (articles)

This corresponds to the only purely cacheable HTML content, which never includes personalized info for the visitor.

# All other content is cached for 30 minutes unless it carries some specific cookies
pattern / simple 30m
0ttl_cookie CUSTOMER          # Will have this once a visitor is logged in
0ttl_cookie CART                   # Will have this once a visitor has started adding things to the cart
0ttl_cookie NEWMESSAGE     # Notifications to user (i.e. product inserted in cart)
0ttl_cookie COMPARE            # Will have this once a visitor has started comparing products
0ttl_cookie nocache                 # Magento provides this hint (in some cases)
0ttl_cookie aicache0ttlcookie    # Caching busted by ourselves