simplecache.rst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Simplecache
  2. ===========
  3. .. seealso::
  4. - :doc:`/admin/performance`
  5. - :doc:`/guides/views`
  6. The Simplecache is a mechanism designed to alleviate the need for certain views to be regenerated dynamically. Instead, they are generated once, saved as a static file, and served in a way that entirely bypasses the Elgg engine.
  7. If Simplecache is turned off (which can be done from the administration panel), these views will be served as normal, with the exception of site CSS.
  8. The criteria for whether a view is suitable for the Simplecache is as follows:
  9. - The view must not change depending on who or when it is being looked at
  10. - The view must not depend on variables fed to it (except for global variables like site URL that never change)
  11. Regenerating the Simplecache
  12. ----------------------------
  13. You can regenerate the Simplecache at any time by:
  14. - Loading ``/upgrade.php``, even if you have nothing to upgrade
  15. - In the admin panel click on 'Flush the caches'
  16. - Enabling or disabling a plugin
  17. - Reordering your plugins
  18. Using the Simplecache in your plugins
  19. -------------------------------------
  20. **Registering views with the Simplecache**
  21. You can register a view with the Simplecache with the following function at init-time:
  22. .. code:: php
  23. elgg_register_simplecache_view($viewname);
  24. **Accessing the cached view**
  25. If you registered a JavaScript or CSS file with Simplecache and put in in the view folder ``js/your_view`` or ``css/your_view`` you can very easily the the url to this cached view by calling
  26. .. code:: php
  27. $url = elgg_get_simplecache_url($type, $view)
  28. Where:
  29. - ``$type`` is js or css
  30. - ``$view`` the view name after css/ or js/