Skip to content

StaticCache Plugin

Jason Coward edited this page Jul 4, 2014 · 5 revisions

Plugin Events

The StaticCache Plugin should be registered on the following MODX Events according to how you want to use it:

  • OnBeforeSaveWebPageCache — The static files are written during this event; the first client to access a Resource will generate the MODX cache file and a static file that can be served directly by the web server. This event is required.
  • OnDocFormSave — This event is only applicable when using the regenerate_on_save feature which will regenerate the static file for a Resource when changes are saved to that Resource.
  • OnSiteRefresh — The statcache_path is cleared on this event, or, optionally, the static files are regenerated without being removed if the regenerate property is set to Yes (1). See the regenerate property details below for additional information on using that feature. Do not register the plugin with this event if you don't want to remote or regenerate the static files.

Plugin Properties

  • cacheTV — Cache all Resources that have a non-empty value in the Template Variable specified in this property value by name. NOTE that this property overrides all other options; leave empty to use other options.
  • skipIfTagsRemain — Skips any Resource that contains non-cacheable tags if this property is set to Yes (1). This is the default behavior.
  • skipTV — Skips any Resource with a non-empty value for the Template Variable specified in this property value by name. Leave empty to only skip non-cacheable Resources.
  • skipBinaryContentTypes — Skip any Resource that has a binary Content Type. This is the default behavior.
  • mimeTypes — If specified and non-empty, only cache Resources associated with the specified mime-types by Content Type. Accepts a comma-delimited list of mime-types.
  • contentTypes — If specified and non-empty, only cache Resources with the specified ContentType id's. Accepts a comma-delimited list of ContentType id's.
  • regenerate — Regenerate static files instead of removing them when clearing site cache. This option requires web server configuration to prevent serving the static files when a client accesses the Resource with an HTTP User-Agent header with the value specified in the regenerate_useragent property (MODX RegenCache by default).
  • regenerate_on_save — Regenerate an existing static file when a Resource is saved in the manager. This option requires the plugin to be registered with the OnDocFormSave event to function and will only regenerate the file if it already exists. This option requires the same web server configuration as regenerate does to prevent serving static files to clients that send the regenerate_useragent value in an HTTP User-Agent header.
  • regenerate_useragent — The User-Agent HTTP header to send when regenerating static files. Your web server should be configured to not serve the static files when the User-Agent equals the value specified here. MODX RegenCache is the default value.
Clone this wiki locally