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

Sorin Sbarnea (Citrix)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 20, 2013

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

0 votes
Answer accepted
Alejandro Conde Carrillo
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 20, 2013

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.

3 votes
Olli Nevalainen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 3, 2014

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"

0 votes
Shay Ben-Haroche December 1, 2014

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!

0 votes
Olli Nevalainen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 27, 2014

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.

0 votes
Shay Ben-Haroche November 27, 2014

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 votes
Brendan Patterson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 6, 2014

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events