opengeek / statcache

Static Caching Extra for MODX Revolution
https://github.com/opengeek/statcache/wiki
16 stars 11 forks source link

Add some helpful info to Wiki #17

Open jgulledge19 opened 10 years ago

jgulledge19 commented 10 years ago

I wrote these out as I just set this up, could help others. Thanks,

Where to begin with statcache and overview of the setup process.

  1. Install via Package Manager
  2. Go to the plugin and attach the correct System events: https://github.com/opengeek/statcache/wiki/StaticCache-Plugin
  3. There are no system settings just Properties to configure statecache: http://rtfm.modx.com/revolution/2.x/making-sites-with-modx/customizing-content/properties-and-property-sets#PropertiesandPropertySets-AssigningPropertySetstoElements
  4. Now clear cache and go to a few pages that are cachable. Note if using default settings there must not be any none cachable snippets/chunks/placeholders on the page. ex: [[!mySnippet]]
  5. Check the statcache directory at the root of your MODX install for files that are written to this folder. If the folder does not exist, create it and make sure PHP can write and modify it. statcache is the default directory.##Now you are ready to add to the .htaccess rules
  6. If you are using urls without the .html then you will need to add an .htaccess file to your statcache directory. Review: https://github.com/opengeek/statcache/wiki#web-server-configuration-issues for complete details
  7. If you are running on NGINX review: https://github.com/opengeek/statcache/wiki#web-server-configuration-for-nginx
  8. If you are running on Apache
    • Open up your .htaccess file that does your MODX friendly URLs. This is most likely in the root of your MODX install.
    • Add the appropriate rules just before the MODX SEF, those will look like this:
# Add statcache rules Here

# END statcache
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Review rules: https://github.com/opengeek/statcache/wiki#web-server-configuration-for-apache
Rewrite cheat sheet: http://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet.html
RewriteCond cheat sheet: http://www.askapache.com/htaccess/rewritecond-cheatsheet.html

500 errors, if you have cPanel then go to Logs -> Error Log and there may be a message in there. Note I did not get the rules in wiki to work with my shared hosting that runs on apache. Here is what I ended up writing:

# Start statcache
RewriteCond %{DOCUMENT_ROOT}/statcache/%{REQUEST_URI}~index.html -f
RewriteRule ^(.*)$ statcache%{REQUEST_URI}~index.html [L,QSA]

RewriteCond %{DOCUMENT_ROOT}/statcache%{REQUEST_URI} -f
RewriteRule ^(.*)$ statcache%{REQUEST_URI} [L,QSA]
# END statcache
ysanmiguel commented 7 years ago

Great, Thank you!