Configuration examples

Empty

Placing an empty config file named IISWebSpeed.config in the root of a website will enable PageSpeed Optimization in a very basic setup for that site using the core filters.


Near-Empty

Instead of placing a completely empty file, the following configuration is somewhat more self-describing:

# enable IISpeed on this webserver
# changes in this file take effect immediately
pagespeed on
            

Starting out from zero

A good approach to PageSpeed optimization is to start out with doing nothing and tune optimizations and options one by one. So we disable the (by default enabled) core filters and IPRO and just start playing with some filters.

# enable IISpeed on this webserver
# changes in this file take effect immediately
pagespeed on
# Do not optimize anything at all, start out blank
pagespeed RewriteLevel PassThrough
pagespeed InPlaceResourceOptimization off
# Iterate using https://my.we-amp.com/pagespeed/test and
# enable filters to fix any recommendations. For example:
pagespeed EnableFilters prioritize_critical_css,rewrite_images
            

HTTPS Support

By default Google PageSpeed doesn't fetch HTTPS resources. Use FetchHttps to enable it.

# enable IISpeed on this webserver
# changes in this file take effect immediately
pagespeed on
# Use default configuration: Core filters and IPRO
# Enable fetching HTTPS resources
pagespeed FetchHttps enable
            

Loading static files from disk

By default PageSpeed loads sub-resources via an HTTP fetch, but offcourse it would be faster to load sub-resources directly from the filesystem.

# enable IISpeed on this webserver
# changes in this file take effect immediately
pagespeed on
# Use default configuration: Core filters and IPRO
# Load all resources whose URLs start with http://www.example.com/static/ from the filesystem under c:\www\static\
pagespeed LoadFromFile "http://www.example.com/static/" "c:\www\static/"
            

Configure the file cache

In order to rewrite resources, PageSpeed must cache them server-side. A file-system based cache is always employed on each server.

# enable IISpeed on this webserver
# changes in this file take effect immediately
pagespeed on
# Use default configuration: Core filters and IPRO
# Configure the file cache
# file cache location:
pagespeed FileCachePath "c:\pagespeed\cache\"
# configure the file cache size
pagespeed FileCacheSizeKb 102400
# interval & treshold the file system cleaner to kick in.
pagespeed FileCacheCleanIntervalMs 3600000
pagespeed FileCacheInodeLimit 500000
# configure the in memory LRU size
pagespeed LRUCacheKbPerProcess 8192
# configure the upper bounday of the size of objects that can be stored
pagespeed LRUCacheByteLimit 16384
            

Use Memcached

When dealing with websites hosted on multiple webservers, having a common cache backend for storing optimized assets make sense. Another benefit is reduced disk I/O as Memcached will take a lot of pressure away from PageSpeed's FileCache.

# enable IISpeed on this webserver
# changes in this file take effect immediately
pagespeed on
# Use default configuration: Core filters and IPRO
# Memcached running on the same machine as the webserver and is listening on its default port
pagespeed MemcachedServers 127.0.0.1:1121
            

Advanced matching example

We'll illustrate IISpeed's more advanced configuration capabilities with an example.

# enable IISpeed on this webserver
# changes in this file take effect immediately
pagespeed on
# Configuring a FileCachePath is mandatory for PageSpeed operation.
# It must be readable and writeable by the user running the website's
# application pool. When the setting does not exist or is invalid
# no optimizations will be applied.
pagespeed FileCachePath "c:\pagespeedcache"
# enable some filters
pagespeed EnableFilters trim_urls,sprite_images,defer_javascript
# You can map urls to filesystem path, to allow loading
# resources from disk instead of through http. Please note that this
# will bypass some of IIS's security checks on urls, so only directories
# that contain public files should be exposed like this
pagespeed LoadFromFile http://foo.com/gfx/ c:\websites\foo.com\gfx\
# we want to disable image rewriting in /foo/
path:/foo/.*
pagespeed DisableFilters rewrite_images
# '!' means: stop matching
# This makes sure that it won't be re-enabled elsewhere
!
# we want to completely reconfigure /foo2/
path:/foo2/.*
# clear will reset the configuration at this point
clear
# We would have to turn pagespeed on again, as it is disabled
# by default inside the root configuration
pagespeed on
pagespeed EnableFilters trim_urls
# we should only have trim_urls enabled at this point.