Clear Cache of Drupal 7 with Custom Code

Yuri Boyz
Yuri Boyz used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
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.
Yuri BoyzSoftware Engineer

Author

Commented:
Yes I have already checked it. But let me test the PHP Code mentioned.
IS there any other update?
Commented:
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

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Yuri BoyzSoftware Engineer

Author

Commented:
Ok let me check this.
Yuri BoyzSoftware Engineer

Author

Commented:
I have checked your last command but it cannot resolve the issue.
Yuri BoyzSoftware Engineer

Author

Commented:
thanks for this.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial