How to flush Confluence cache from the command line, without restarting Confluence?

I am looking for a solution to flush Confluence cache without restarting the service.

It has to be a scriptable solution, one that I can include inside a script.

6 answers

1 accepted

If you mean Confluence plugin cache. The cache are used to keep frequently used information handy. If you clear it without restarting Confluence, that will make some plugins fail.

If you mean Conflnuence cache, you can flush it from the user interface in "Confluence Admin" > "Cache Statistics" but unfortunately there is not a method in the API for this so I don't think it can be easily scripted.

2 votes

The following script works from Confluence 5.5 onward and flushes all the caches:

#!/bin/sh

HOST=$1
USERNAME="admin"
PASSWORD="xxx"

JSESSIONID=`curl --cookie-jar - --data "os_username=$USERNAME&os_password=$PASSWORD" "$HOST/dologin.action" | grep JSESSIONID | awk '{ print $7 }'`
curl --cookie JSESSIONID=$JSESSIONID --request DELETE "$HOST/rest/cacheManagement/1.0/cacheEntries"

You could write a command line script to access the Admin screen llinks mentioned by Alex using curl or something. You can pass credentials in at the command line to authenticated...though you'll have to circumnavigate the second admin login.

Olli, I've tried your script but am getting this error:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method DELETE is not allowed for the URL /rest/cacheManagement/1.0/cacheEntries.</p>
<hr>
<address>Apache/2.2.15 (Red Hat) Server at localhost Port 80</address>
</body></html>

 

Can you advise?

Thanks!

0 vote

Hi Shay,

You seem to get that error from an Apache instance that is sitting in front of your Confluence instance. You would have to ask the administrator of that instance why it is blocking your DELETE request.

Hi Olli,

Thanks for the very quick response smile

My problem turned out to be the fact I gave the hostname as just "HOST" parameter as just the hostname (MYSERVER) and not the http address to Confluence (http://MYSERVER:8090).

 

Thanks again!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

900 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you