-
Notifications
You must be signed in to change notification settings - Fork 20
Static cache setup
Follow these steps to setup static caching:
-
Create a cache directory (e.g. 'static_cache') in your public webroot and CHMOD to 777 (or CHOWN to the user PHP runs as).
-
Set 'stash_static_basepath' to the full path of your newly created cache directory in your config.
-
Set 'stash_static_url' to the absolute or root-relative URL of the cache directory in your config.
-
Set 'stash_static_cache_enabled' to TRUE in your config.
-
If you are using Mustash, visit the 'Stash cache rewrite rules' page in Settings to view an auto-generated htaccess file that you can copy and paste into your public webroot. Alternatively, edit the .htaccess file below with the path and url to your static cache directory, and save it in your public webroot. Replace '[site_id]' with the id of your site. If you are using MSM, create an .htaccess file for each site and save it in the site's directory.
htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
#################################################################################
# START STASH STATIC CACHE
# Exclude POST requests
RewriteCond %{REQUEST_METHOD} !=POST
# Exclude CSS/ACT EE URLs
RewriteCond %{QUERY_STRING} !^(css|ACT|URL)
# Remove index.php from conditions
RewriteCond $1 ^(index.php/)*(.*)(/*)$
# Check if cached index.html exists
RewriteCond /path/to/static_cache/[site_id]/$2/index.html (.*\.(.*))$
RewriteCond %1 -f
# Rewrite to the cached page
RewriteRule ^(index.php/*)*(.*)(/*) http://www.my-site.com/static_cache/[site_id]/$2/index.%2 [L]
# END STASH STATIC CACHE RULES
#################################################################################
# -------------------------------------------------------------------------------
# Officially supported method to remove index.php from ExpressionEngine URLs
# See: http://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html
# -------------------------------------------------------------------------------
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
Getting started
Using Stash
Using Mustash
- Mustash
- Installing Mustash
- Managing variables
- Managing bundles
- Cache-breaking rules
- Mustash plugins
- Mustash Varnish plugin
- Mustash plugin development
- Mustash API
Template design patterns
Tag reference
- {exp:stash:set}
- {exp:stash:get}
- {exp:stash:block}
- {exp:stash:set_value}
- {exp:stash:append}
- {exp:stash:append_value}
- {exp:stash:prepend}
- {exp:stash:prepend_value}
- {exp:stash:copy}
- {exp:stash:context}
- {exp:stash:is_empty}
- {exp:stash:not_empty}
- {exp:stash:set_list}
- {exp:stash:get_list}
- {exp:stash:append_list}
- {exp:stash:prepend_list}
- {exp:stash:split_list}
- {exp:stash:join_lists}
- {exp:stash:list_count}
- {exp:stash:unset}
- {exp:stash:flush_cache}
- {exp:stash:bundle}
- {stash:embed}
- {exp:stash:extend}
- {exp:stash:parse}
- {exp:stash:cache}
- {exp:stash:static}
- {exp:stash:finish}
- {exp:stash:not_found}
- Short tag syntax
- Using Stash methods in your own add-ons