Body: <p>I'm having an issue whereby clearing Civi cache is the only way to make some fields visible on a Drupal 7 user profile. I've tried to debug the issue and it seems to be caused by anonymous users viewing the account, where they don't have the permission to view those fields and it caches that result of seeing nothing.</p>
  
  <p>My issue for now however, is that in Drupal's sites/default/civicrm.settings.php file, I've set the cache to:</p>
  
  <pre><code>  define('CIVICRM_DB_CACHE_CLASS', 'NoCache');
  </code></pre>
  
  <p>I've debugged it and check that <code>CIVICRM_DB_CACHE_CLASS</code> has not already been defined but Civi is still caching those results. How can I fix this or how else can I turn off Civi caching?</p>
  
  <p>Logged in as admin, this is what the profile looks like before clearing caches:
  <a href="https://i.sstatic.net/bqA2k.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bqA2k.png" alt="Missing fields before cache clear"></a></p>
  
  <p>And then after clearing caches:
  <a href="https://i.sstatic.net/9vwVp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9vwVp.png" alt="Fields after clearing cache"></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-29T12:22:52.790Z
Comments.Text: It sounds like your issue is compiled Smarty templates, not traditional caching. Could you edit your question to include a screenshot so folks can better assess?
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-29T14:09:10.973Z
Comments.Text: Of the fields that would be missing or the templates_c directory? TIA for helping
Comments.UserDisplayName: AlbionBrown
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-29T20:27:16.160Z
Comments.Text: A screenshot of the missing fields.  You can also try deleting `templates_c` and immediately reload the page.  If you see a difference, we've isolated the problem and  can work on finding the root cause.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-30T10:45:23.320Z
Comments.Text: Annoyingly, the cache is behaving itself this morning, it wasn't yesterday. So, I might need to follow this up later today/tomorrow.
Comments.UserDisplayName: AlbionBrown
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-31T09:25:22.757Z
Comments.Text: I tired clearing down the templates_c directory but it didn't seem to do anything. When I've stepped through it with xdebug it doesn't seem to make any contact with templates_c, only the civicrm_cache table. But I've edited for those screenshots now.
Comments.UserDisplayName: AlbionBrown
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-31T11:13:43.343Z
Comments.Text: What version of Civi? (this sounds familiar - like a bug we might have fixed?)
Comments.UserDisplayName: eileen
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-31T17:26:02.583Z
Comments.Text: @JoshBrown Am I misunderstanding the screenshots?  Those look like entirely different profiles, not one profile with some fields missing.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-03T09:28:55.910Z
Comments.Text: @eileen Civi version is 5.20.2
Comments.UserDisplayName: AlbionBrown
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-03T09:53:05.370Z
Comments.Text: @JonG-MegaphoneTech It's definitely the same user profile. If I clear the caches and view the profile as the anonymous user, that set of fields disappear (Bio, RePEc author ID etc). I also just found out that the set of fields that stay visible is one set of custom fields and the set that disappear is another set, but they're both pulled into the same profile field set. Maybe that's where the problem could be.
Comments.UserDisplayName: AlbionBrown
Tags: <drupal><civicrm.settings.php><cache>
Title: Setting CiviCRM to NoCache doesn't work
ThreadText: # Setting CiviCRM to NoCache doesn't work
  
  (Asked by: username_0 on 2020-01-29)
  
  I'm having an issue whereby clearing Civi cache is the only way to make some fields visible on a Drupal 7 user profile. I've tried to debug the issue and it seems to be caused by anonymous users viewing the account, where they don't have the permission to view those fields and it caches that result of seeing nothing.
  My issue for now however, is that in Drupal's sites/default/civicrm.settings.php file, I've set the cache to:
    define('CIVICRM_DB_CACHE_CLASS', 'NoCache');
  
  I've debugged it and check that CIVICRM_DB_CACHE_CLASS has not already been defined but Civi is still caching those results. How can I fix this or how else can I turn off Civi caching?
  Logged in as admin, this is what the profile looks like before clearing caches:
  
  And then after clearing caches:
  
  **Tags:** drupal, civicrm.settings.php, cache
  
  > **Comments:**
  > **username_1**: It sounds like your issue is compiled Smarty templates, not traditional caching. Could you edit your question to include a screenshot so folks can better assess?  
  > **username_0**: Of the fields that would be missing or the templates_c directory? TIA for helping  
  > **username_1**: A screenshot of the missing fields.  You can also try deleting `templates_c` and immediately reload the page.  If you see a difference, we've isolated the problem and  can work on finding the root cause.  
  > **username_0**: Annoyingly, the cache is behaving itself this morning, it wasn't yesterday. So, I might need to follow this up later today/tomorrow.  
  > **username_0**: I tired clearing down the templates_c directory but it didn't seem to do anything. When I've stepped through it with xdebug it doesn't seem to make any contact with templates_c, only the civicrm_cache table. But I've edited for those screenshots now.  
  > **username_2**: What version of Civi? (this sounds familiar - like a bug we might have fixed?)  
  > **username_1**: @JoshBrown Am I misunderstanding the screenshots?  Those look like entirely different profiles, not one profile with some fields missing.  
  > **username_0**: @username_2 Civi version is 5.20.2  
  > **username_0**: @JonG-MegaphoneTech It's definitely the same user profile. If I clear the caches and view the profile as the anonymous user, that set of fields disappear (Bio, RePEc author ID etc). I also just found out that the set of fields that stay visible is one set of custom fields and the set that disappear is another set, but they're both pulled into the same profile field set. Maybe that's where the problem could be.  
  
  ---
  
  ## 0 answers
  
  