@DeleteMapping
    @Operation(summary = "Invalidate SAML2 metadata cache using a service id or entity id. The service id could be the registered service numeric identifier, its name or actual service id. "
        + "In case the service definition points to an aggregate, you may also specify an entity id to locate the service provider within that aggregate. "
        + "If you do not specify any parameters, all entries in the metadata cache will be invalidated.",
        parameters = {
            @Parameter(name = "serviceId", description = "The service id"),
            @Parameter(name = "entityId", description = "The entity id")
        })
    public ResponseEntity invalidate(
        @Nullable
        @RequestParam(required = false) final String serviceId,
        @Nullable
        @RequestParam(required = false) final String entityId) throws Throwable {

        if (StringUtils.isBlank(serviceId)) {
            cachingMetadataResolver.getObject().invalidate();
            LOGGER.info("Cleared SAML2 registered service metadata cache");
            return ResponseEntity.noContent().build();
        }
        val registeredService = findRegisteredService(serviceId);
        val criteriaSet = new CriteriaSet();
        val effectiveEntityId = StringUtils.defaultIfBlank(entityId, registeredService.getServiceId());
        criteriaSet.add(new EntityIdCriterion(effectiveEntityId));
        criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
        cachingMetadataResolver.getObject().invalidate(registeredService, criteriaSet);
        LOGGER.info("Invalidated SAML2 registered service metadata cache entry for [{}]", registeredService);
        return ResponseEntity.noContent()
            .header(registeredService.getClass().getSimpleName(), String.valueOf(registeredService.getId()), registeredService.getName())
            .header(EntityIdCriterion.class.getSimpleName(), effectiveEntityId)
            .build();
    }
Invalidate.

@param serviceId the service id
@param entityId  the entity id
@return the response entity
@throws Throwable the throwable
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/metadata/SamlRegisteredServiceCachedMetadataEndpoint.java