include template with link

I'm trying to clear the cache in an admin area via a link on a page. My link right now is
<cfoutput><a href="members/act_clearcached.cfm">Clear Cache</a></cfoutput>

I don't really wqant to go to the page. I want it to include the template act_clearcached.cfm when it reloads.

what is missing here?
Who is Participating?
_agx_Connect With a Mentor Commented:
No, you can't use cfinclude in a anchor tag.

1. You could either redirect to a page that includes that template. Then return to the previous page OR
2. Create a link to the current page with a paramater:
<a href="thePageWhereYouhaveTheLink.cfm?clearIt=true">Clear Cache</a>

Then at the top of the page, include the template only if that parameter exists:

<cfif structKeyExists(url, "clearIt")>
     <cfsilent><cfinclude template="members/act_clearcached.cfm"></cfsilent>

Assuming the template generates no output, cfinclude it:

<cfinclude template="act_clearcached.cfm">  

<cfinclude template="members/act_clearcached.cfm">
ShawnAuthor Commented:
but I want it to happen only when the link is clicked on. Would it be something like

<cfoutput><a href="<cfinclude template="members/act_clearcached.cfm"> ">Clear Cache</a></cfoutput>

act_clearcached.cfm does have a little output. see below
<cfobjectcache action="clear">
<div align="center"><strong>All cached objects should now be cleared.</strong></div>

Open in new window

ShawnAuthor Commented:
tried solution 2 and works like a charm

thanks agx
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.

All Courses

From novice to tech pro — start learning today.