MCPcopy Create free account
hub / github.com/apache/httpd / cache_invalidate

Function cache_invalidate

modules/cache/cache_storage.c:690–790  ·  view source on GitHub ↗

* Invalidate a specific URL entity in all caches * * All cached entities for this URL are removed, usually in * response to a POST/PUT or DELETE. * * This function returns OK if at least one entity was found and * removed, and DECLINED if no cached entities were removed. */

Source from the content-addressed store, hash-verified

688 * removed, and DECLINED if no cached entities were removed.
689 */
690int cache_invalidate(cache_request_rec *cache, request_rec *r)
691{
692 cache_provider_list *list;
693 apr_status_t rv, status = DECLINED;
694 cache_handle_t *h;
695 apr_uri_t location_uri;
696 apr_uri_t content_location_uri;
697
698 const char *location, *location_key = NULL;
699 const char *content_location, *content_location_key = NULL;
700
701 if (!cache) {
702 /* This should never happen */
703 ap_log_rerror(
704 APLOG_MARK, APLOG_ERR, APR_EGENERAL, r, APLOGNO(00697) "cache: No cache request information available for key"
705 " generation");
706 return DECLINED;
707 }
708
709 if (!cache->key) {
710 rv = cache_generate_key(r, r->pool, &cache->key);
711 if (rv != APR_SUCCESS) {
712 return DECLINED;
713 }
714 }
715
716 location = apr_table_get(r->headers_out, "Location");
717 if (location) {
718 if (apr_uri_parse(r->pool, location, &location_uri)
719 || cache_canonicalise_key(r, r->pool,
720 location_uri.path,
721 location_uri.query,
722 &location_uri, &location_key)
723 || !(r->parsed_uri.hostname
724 && location_uri.hostname
725 && !strcmp(r->parsed_uri.hostname,
726 location_uri.hostname))) {
727 location_key = NULL;
728 }
729 }
730
731 content_location = apr_table_get(r->headers_out, "Content-Location");
732 if (content_location) {
733 if (apr_uri_parse(r->pool, content_location,
734 &content_location_uri)
735 || cache_canonicalise_key(r, r->pool,
736 content_location_uri.path,
737 content_location_uri.query,
738 &content_location_uri,
739 &content_location_key)
740 || !(r->parsed_uri.hostname
741 && content_location_uri.hostname
742 && !strcmp(r->parsed_uri.hostname,
743 content_location_uri.hostname))) {
744 content_location_key = NULL;
745 }
746 }
747

Callers 1

cache_invalidate_filterFunction · 0.85

Calls 1

cache_canonicalise_keyFunction · 0.85

Tested by

no test coverage detected