• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 90
  • Last Modified:

Clear Cache of Drupal 7 with Custom Code

In my Drupal 7 Website, I have called an Ajax function by the click of a  button to do some Database modifications by different queries. Everything goes well but in the end I need to remove the cache also via code. My file is in /templates folder. I have tried various search functions of drupal to clear cache but nothing works.

Can any drupal 7 expert guide that how to clear the cache.

Note:  I am working on my custom functionality to Revert the Page contents to the last state. Everything goes well but when  I clear the cache then user will be able to see fresh content otherwise not. So I need to clear cache via my ajax code.

Looking forward for reply.

Thanks
0
Shano Khan
Asked:
Shano Khan
  • 4
  • 2
1 Solution
 
MishaProgrammerCommented:
Do you read this article?

https://www.drupal.org/docs/7/administering-drupal-7-site/clearing-or-rebuilding-drupals-cache

There is some methods to remove cashe in other situation, if I correct understand your question.
0
 
Shano KhanSoftware EngineerAuthor Commented:
Yes I have already checked it. But let me test the PHP Code mentioned.
IS there any other update?
0
 
MishaProgrammerCommented:
And what about javascript?

cache_clear_all()
drupal_flush_all_caches()

Open in new window


If you wanr to drop specifics caches, you can try something like this:

ache_clear_all('*', 'cache', TRUE);
    cache_clear_all('*', 'content', TRUE);
    cache_clear_all('*', 'cache_page', TRUE);
    cache_clear_all('*', 'cache_menu', TRUE);
    cache_clear_all('*', 'cache_filter', TRUE);
    cache_clear_all('*', 'cache_view', TRUE);

Open in new window

0
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
Shano KhanSoftware EngineerAuthor Commented:
Ok let me check this.
0
 
Shano KhanSoftware EngineerAuthor Commented:
I have checked your last command but it cannot resolve the issue.
0
 
Shano KhanSoftware EngineerAuthor Commented:
thanks for this.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now