Answers.Body: <p>+1 for Joe's comment which is pretty thorough.</p>
  
  <p>Re: <code>drush cc all</code> -- this command can be pretty important in the workflow for Drupal dev. In Civi-Drupal, the analogous command is <code>drush cvapi system.flush</code> In Civi-Wordpress, it's <code>wp civicrm api system.flush</code> . (Or, if you're more into Firebug's CLI, <code>CRM.api3('system','flush')</code>)</p>
  
  <p>Note: Despite the anachronistic naming, "/civicrm/menu/rebuild" is basically the same thing, and so is "/civicrm/clearcache". Internally, all of these commands are wrappers for <code>CRM_Core_Invoke::rebuildMenuAndCaches()</code> (aka the grand-daddy of all flushing functions in Civi).</p>
  
  <p>If there are any caches in the civicrm-core codebase that are omitted by <code>CRM_Core_Invoke::rebuildMenuAndCaches()</code>, then that's a bug, and patches to flush more caches would be welcome.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-28T14:52:34.990Z
Answers.Text: I had a question related to this, not sure why you would need to run `drush cc civicrm` separately from `drush cc all` https://civicrm.stackexchange.com/questions/21376/is-the-container-cache-not-cleared-as-part-of-drush-cc-all
Answers.UserDisplayName: mickadoo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-26T05:24:55.353Z
Answers.LastActivityDate: 2015-03-26T05:24:55.353Z
Answers.UserDisplayName: Tim Otten
Answers.Body: <p>For the first example, you need to 1. clear the compiled Smarty templates cache. In the second case you need to 2. rebuild the menu system using your xml file. 3. There are some db cache tables you sometimes need to clear out using mysql or a link in the UI. 4. Caching in the CMS can also affect CiviCRM pages.</p>
  
  <ol>
  <li>a) One way to do this is to go to Admin > System Settings > Cleanup Caches and Update Paths (civicrm/admin/setting/updateConfigBackend?reset=1), then click Save.</li>
  </ol>
  
  <p>b) A more convenient method during development is to be able to append arguments to the url you are debugging to have the cleanup done automatically. Go to Administer > System Settings > Debugging and Error Handling.</p>
  
  <p>Click to Enable Debugging. At this point you can add a key-value pair to your URLs to clear the compiled Smarty file cache under templates_c, and also if you want the upload file directory:
  Directory Cleanup -Empties template cache and/or temporary upload file folders.
  To empty template cache (civicrm/templates_c folder), add &amp;directoryCleanup=1
  To remove temporary upload files (civicrm/upload folder), add &amp;directoryCleanup=2
  To cleanup both, add &amp;directoryCleanup=3</p>
  
  <p>You might also want reset the session, since that caches various values: 
  Session Reset - Resets all values in your client session. To trigger, add &amp;sessionReset=2</p>
  
  <ol start="2">
  <li>a) Enter the appropriate one of the following urls to rebuild the menu system, which also clears various caches:</li>
  </ol>
  
  <p>Drupal sites: http:///index.php?q=civicrm/menu/rebuild&amp;reset=1</p>
  
  <p>Joomla 1.5 sites: http:///administrator/index2.php?option=com_civicrm&amp;task=civicrm/menu/rebuild&amp;reset=1</p>
  
  <p>Joomla 1.6 sites: http:///administrator/index.php?option=com_civicrm&amp;task=civicrm/menu/rebuild&amp;reset=1</p>
  
  <p>Wordpress sites: http:///wp-admin/admin.php?page=CiviCRM&amp;q=civicrm/menu/rebuild&amp;reset=1</p>
  
  <p>This action also resets the IDS (intrusion detection system) file. </p>
  
  <p>b) As explained in @Tim Otten's answer, this can be done conveniently from the commandline as well, using a better named wrapper for the same actions:</p>
  
  <p>In Civi-Drupal, the analogous command is:
  $ drush cvapi system.flush </p>
  
  <p>In Civi-Wordpress, it's:
  $ wp civicrm api system.flush . </p>
  
  <p>Or alternatively, in Firebug's CLI: CRM.api3('system','flush'))</p>
  
  <ol start="3">
  <li>There are other sorts of caches that may occasionally need to be reset. 
  a) At Contacts > Manage Groups, it is possible to reset the caches for contacts that are in Smart Groups by clicking near the top left of the page the Update Smart Group Counts link.</li>
  </ol>
  
  <p>b) More generally, depending on the area of CiviCRM you are working on you may need to truncate any of the CiviCRM tables that have cache in their name:</p>
  
  <pre><code>mysql&gt; show tables like '%cache%';
  +-------------------------------------+
  | Tables_in_clubcdn_civ_new (%cache%) |
  +-------------------------------------+
  | civicrm_acl_cache                   |
  | civicrm_acl_contact_cache           |
  | civicrm_cache                       |
  | civicrm_group_contact_cache         |
  | civicrm_prevnext_cache              |
  +-------------------------------------+
  5 rows in set (0.00 sec)
  </code></pre>
  
  <p>Use TRUNCATE civicrm_acl_cache; or similar queries on the command line or in phpMyAdmin to clear these tables.</p>
  
  <ol start="4">
  <li>CMSes have their own caches that can often cause grief when developing in CiviCRM. For example, in Drupal 7, go to Configuration > and in Development set of modules click on Performance. Click to purge the caches. You might also want to disable caching of pages for anonymous users, caching of blocks, and / or aggregrating and compressing css and javascript files.</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-25T17:39:32.213Z
Answers.LastActivityDate: 2015-03-26T19:08:43.467Z
Answers.LastEditDate: 2015-03-26T19:08:43.467Z
Answers.UserDisplayName: Joe Murray
Body: <p>When doing developpment, i sometimes found it difficult to clear all the cache in a way i'm sure everything i have done is taken into account.</p>
  
  <p>Let's take some examples :</p>
  
  <ul>
  <li>in an extension, i do an override of some core .tpl file (i know i shouldn't do that but sometimes difficult to avoid) - will it work out of the box or do i need to clear some cache ?</li>
  <li>in an extension, i create a new page or form with a custom menu xml file - what do i need to clean ?</li>
  </ul>
  
  <p>What are the different level of caches involved ?</p>
  
  <p>Is there a way to clean all caches in one shot like the drupal <code>Flush all caches</code> / <code>drush cc all</code> ?</p>
  
Tags: <extension><developer>
Title: What are the different cache clearing mechanisms relevant when developing?
ThreadText: # What are the different cache clearing mechanisms relevant when developing?
  
  (Asked by: username_0 on 2015-03-25)
  
  When doing developpment, i sometimes found it difficult to clear all the cache in a way i'm sure everything i have done is taken into account.
  
  Let's take some examples :
  
  * in an extension, i do an override of some core .tpl file (i know i shouldn't do that but sometimes difficult to avoid) - will it work out of the box or do i need to clear some cache ?
  * in an extension, i create a new page or form with a custom menu xml file - what do i need to clean ?
  
  What are the different level of caches involved ?
  
  Is there a way to clean all caches in one shot like the drupal `Flush all caches` / `drush cc all` ?
  
  **Tags:** extension, developer
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2015-03-25. Score: 15 | Accepted answer
  
  For the first example, you need to 1. clear the compiled Smarty templates cache. In the second case you need to 2. rebuild the menu system using your xml file. 3. There are some db cache tables you sometimes need to clear out using mysql or a link in the UI. 4. Caching in the CMS can also affect CiviCRM pages.
  
  1. a) One way to do this is to go to Admin > System Settings > Cleanup Caches and Update Paths (civicrm/admin/setting/updateConfigBackend?reset=1), then click Save.
  
  b) A more convenient method during development is to be able to append arguments to the url you are debugging to have the cleanup done automatically. Go to Administer > System Settings > Debugging and Error Handling.
  
  Click to Enable Debugging. At this point you can add a key-value pair to your URLs to clear the compiled Smarty file cache under templates\_c, and also if you want the upload file directory:
  Directory Cleanup -Empties template cache and/or temporary upload file folders.
  To empty template cache (civicrm/templates\_c folder), add &directoryCleanup=1
  To remove temporary upload files (civicrm/upload folder), add &directoryCleanup=2
  To cleanup both, add &directoryCleanup=3
  
  You might also want reset the session, since that caches various values:
  Session Reset - Resets all values in your client session. To trigger, add &sessionReset=2
  
  2. a) Enter the appropriate one of the following urls to rebuild the menu system, which also clears various caches:
  
  Drupal sites: http:///index.php?q=civicrm/menu/rebuild&reset=1
  
  Joomla 1.5 sites: http:///administrator/index2.php?option=com\_civicrm&task=civicrm/menu/rebuild&reset=1
  
  Joomla 1.6 sites: http:///administrator/index.php?option=com\_civicrm&task=civicrm/menu/rebuild&reset=1
  
  Wordpress sites: http:///wp-admin/admin.php?page=CiviCRM&q=civicrm/menu/rebuild&reset=1
  
  This action also resets the IDS (intrusion detection system) file.
  
  b) As explained in @username_1's answer, this can be done conveniently from the commandline as well, using a better named wrapper for the same actions:
  
  In Civi-Drupal, the analogous command is:
  $ drush cvapi system.flush
  
  In Civi-Wordpress, it's:
  $ wp civicrm api system.flush .
  
  Or alternatively, in Firebug's CLI: CRM.api3('system','flush'))
  
  3. There are other sorts of caches that may occasionally need to be reset.
     a) At Contacts > Manage Groups, it is possible to reset the caches for contacts that are in Smart Groups by clicking near the top left of the page the Update Smart Group Counts link.
  
  b) More generally, depending on the area of CiviCRM you are working on you may need to truncate any of the CiviCRM tables that have cache in their name:
  
  ```
  mysql> show tables like '%cache%';
  +-------------------------------------+
  | Tables_in_clubcdn_civ_new (%cache%) |
  +-------------------------------------+
  | civicrm_acl_cache                   |
  | civicrm_acl_contact_cache           |
  | civicrm_cache                       |
  | civicrm_group_contact_cache         |
  | civicrm_prevnext_cache              |
  +-------------------------------------+
  5 rows in set (0.00 sec)
  
  ```
  
  Use TRUNCATE civicrm\_acl\_cache; or similar queries on the command line or in phpMyAdmin to clear these tables.
  
  4. CMSes have their own caches that can often cause grief when developing in CiviCRM. For example, in Drupal 7, go to Configuration > and in Development set of modules click on Performance. Click to purge the caches. You might also want to disable caching of pages for anonymous users, caching of blocks, and / or aggregrating and compressing css and javascript files.
  
  
  ---
  
  ### Answer by username_1 on 2015-03-26. Score: 9
  
  +1 for Joe's comment which is pretty thorough.
  
  Re: `drush cc all` -- this command can be pretty important in the workflow for Drupal dev. In Civi-Drupal, the analogous command is `drush cvapi system.flush` In Civi-Wordpress, it's `wp civicrm api system.flush` . (Or, if you're more into Firebug's CLI, `CRM.api3('system','flush')`)
  
  Note: Despite the anachronistic naming, "/civicrm/menu/rebuild" is basically the same thing, and so is "/civicrm/clearcache". Internally, all of these commands are wrappers for `CRM_Core_Invoke::rebuildMenuAndCaches()` (aka the grand-daddy of all flushing functions in Civi).
  
  If there are any caches in the civicrm-core codebase that are omitted by `CRM_Core_Invoke::rebuildMenuAndCaches()`, then that's a bug, and patches to flush more caches would be welcome.
  
  > **Comments:**
  > **username_2**: I had a question related to this, not sure why you would need to run `drush cc civicrm` separately from `drush cc all` https://civicrm.stackexchange.com/questions/21376/is-the-container-cache-not-cleared-as-part-of-drush-cc-all  
  
  ---
  
  