# Invalidate cache of Nexus group repository via Groovy

**URL:** <https://community.sonatype.com/t/invalidate-cache-of-nexus-group-repository-via-groovy/9865>\
**Category:** Sonatype Nexus Repository\
**Tags:** nexus-repository\
**Created:** [January 5, 2023, 2:23pm UTC](https://community.sonatype.com/t/invalidate-cache-of-nexus-group-repository-via-groovy/9865 "2023-01-05T14:23:08Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![nikable](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@nikable](https://community.sonatype.com/u/nikable)\
**Post date:** [January 5, 2023, 2:23pm UTC](https://community.sonatype.com/t/invalidate-cache-of-nexus-group-repository-via-groovy/9865/1 "2023-01-05T14:23:10Z")

</div>

Hello Community,

Is there any preferred method to **invalidate cache via a Groovy script** which can be executed by Nexus task executor?

Following the groovy scripting guide provided at ([GitHub - sonatype-nexus-community/nexus-scripting-examples: Sample scripts that use NXRM's scripting interface](https://github.com/sonatype-nexus-community/nexus-scripting-examples)).

I think the **Repository API for scripts** ([REST and Integration API](https://help.sonatype.com/repomanager3/integrations/rest-and-integration-api#RESTandIntegrationAPI-ScriptingAPI)) only allows to view the content/ **create new repositories via Groovy**. Could this API be somehow extended to invalidate group repository cache via Groovy?

Would manually creating an Object of RepositoryCacheInvalidationService class in Groovy ([nexus-public/RepositoryCacheInvalidationService.java at main · sonatype/nexus-public · GitHub](https://github.com/sonatype/nexus-public/blob/main/components/nexus-repository-services/src/main/java/org/sonatype/nexus/repository/cache/RepositoryCacheInvalidationService.java)) to call cache invalidation function work? Or could there be a better way to handle it via Groovy?

As of now I could only found a way to do it via a cURL POST request \<nexus-url/service/rest/v1/repositories/npm-group/invalidate-cache\> .

Many thanks in advance for your support.

Cheers

---

_[View the full topic](https://community.sonatype.com/t/invalidate-cache-of-nexus-group-repository-via-groovy/9865)._
