WordPress at a glance
function is not described

wp_cache_shutdown_callback() WPSCache 1.0

Hooks from the function
Return

Null. Nothing.

Usage

wp_cache_shutdown_callback();

Code of wp_cache_shutdown_callback() WPSCache 1.7.1

<?php
function wp_cache_shutdown_callback() {
	global $cache_max_time, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $supercacheonly, $blog_cache_dir;
	global $wp_cache_request_uri, $wp_cache_key, $cache_enabled, $wp_cache_blog_charset, $wp_cache_not_logged_in;
	global $WPSC_HTTP_HOST, $wp_super_cache_query;

	if ( ! function_exists( 'wpsc_init' ) ) {
		/*
		 * If a server has multiple networks the plugin may not have been activated
		 * on all of them. Give feeds on those blogs a short TTL.
		 * ref: https://wordpress.org/support/topic/fatal-error-while-updating-post-or-publishing-new-one/
		 */
		$wpsc_feed_ttl = 1;
		wp_cache_debug( 'wp_cache_shutdown_callback: Plugin not loaded. Setting feed ttl to 60 seconds.' );
	}


	if ( false == $new_cache ) {
		wp_cache_debug( 'wp_cache_shutdown_callback: No cache file created. Returning.' );
		return false;
	}

	$wp_cache_meta[ 'uri' ] = $WPSC_HTTP_HOST . preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $wp_cache_request_uri); // To avoid XSS attacks
	$wp_cache_meta[ 'blog_id' ] = $blog_id;
	$wp_cache_meta[ 'post' ] = wp_cache_post_id();
	$wp_cache_meta[ 'key' ] = $wp_cache_key;
	$wp_cache_meta = apply_filters( 'wp_cache_meta', $wp_cache_meta );

	$response = wp_cache_get_response_headers();
	foreach( $response as $key => $value ) {
		$wp_cache_meta[ 'headers' ][ $key ] = "$key: $value";
	}

	wp_cache_debug( 'wp_cache_shutdown_callback: collecting meta data.', 2 );

	if (!isset( $response['Last-Modified'] )) {
		$value = gmdate('D, d M Y H:i:s') . ' GMT';
		/* Dont send this the first time */
		/* @header('Last-Modified: ' . $value); */
		$wp_cache_meta[ 'headers' ][ 'Last-Modified' ] = "Last-Modified: $value";
	}
	$is_feed = false;
	if ( !isset( $response[ 'Content-Type' ] ) && !isset( $response[ 'Content-type' ] ) ) {
		// On some systems, headers set by PHP can't be fetched from
		// the output buffer. This is a last ditch effort to set the
		// correct Content-Type header for feeds, if we didn't see
		// it in the response headers already. -- dougal
		if ( isset( $wp_super_cache_query[ 'is_feed' ] ) ) {
			if ( isset( $wp_super_cache_query[ 'is_sitemap' ] ) )  {
				$type  = 'sitemap';
				$value = 'text/xml';
			} else {
				$type = get_query_var( 'feed' );
				$type = str_replace('/','',$type);
				switch ($type) {
					case 'atom':
						$value = 'application/atom+xml';
						break;
					case 'rdf':
						$value = 'application/rdf+xml';
						break;
					case 'rss':
					case 'rss2':
					default:
						$value = 'application/rss+xml';
				}
			}
			$is_feed = true;

			if ( isset( $wpsc_feed_ttl ) && $wpsc_feed_ttl == 1 ) {
				$wp_cache_meta[ 'ttl' ] = 60;
			}
			$is_feed = true;

			wp_cache_debug( "wp_cache_shutdown_callback: feed is type: $type - $value" );
		} elseif ( isset( $wp_super_cache_query[ 'is_rest' ] ) ) { // json
			$value = 'application/json';
		} else { // not a feed
			$value = get_option( 'html_type' );
			if( $value == '' )
				$value = 'text/html';
		}
		$value .=  "; charset=\"" . $wp_cache_blog_charset . "\"";

		wp_cache_debug( "Sending 'Content-Type: $value' header.", 2 );
		@header("Content-Type: $value");
		$wp_cache_meta[ 'headers' ][ 'Content-Type' ] = "Content-Type: $value";
	}

	if ( $cache_enabled && !$supercacheonly && $new_cache ) {
		if( !isset( $wp_cache_meta[ 'dynamic' ] ) && $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta[ 'headers' ] ) ) {
			wp_cache_debug( 'Sending gzip headers.', 2 );
			$wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
			if ( defined( 'WPSC_VARY_HEADER' ) ) {
				if ( WPSC_VARY_HEADER != '' ) {
					$vary_header = WPSC_VARY_HEADER;
				} else {
					$vary_header = '';
				}
			} else {
				$vary_header = 'Accept-Encoding, Cookie';
			}
			if ( $vary_header ) {
				$wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: ' . $vary_header;
			}
		}

		$serial = '<?php die(); ?>' . json_encode( $wp_cache_meta );
		$dir = get_current_url_supercache_dir();
		if( @is_dir( $dir ) == false )
			@wp_mkdir_p( $dir );

		if( wp_cache_writers_entry() ) {
			wp_cache_debug( "Writing meta file: {$dir}meta-{$meta_file}", 2 );

			$tmp_meta_filename = $dir . uniqid( mt_rand(), true ) . '.tmp';
			$final_meta_filename = $dir . "meta-" . $meta_file;
			$fr = @fopen( $tmp_meta_filename, 'w');
			if ( $fr ) {
				fputs($fr, $serial);
				fclose($fr);
				@chmod( $tmp_meta_filename, 0666 & ~umask());
				if( !@rename( $tmp_meta_filename, $final_meta_filename ) ) {
					@unlink( $dir . $final_meta_filename );
					@rename( $tmp_meta_filename, $final_meta_filename );
				}
			} else {
				wp_cache_debug( "Problem writing meta file: {$final_meta_filename}" );
			}
			wp_cache_writers_exit();

			// record locations of archive feeds to be updated when the site is updated.
			// Only record a maximum of 50 feeds to avoid bloating database.
			if ( ( isset( $wp_super_cache_query[ 'is_feed' ] ) || $is_feed ) && ! isset( $wp_super_cache_query[ 'is_single' ] ) ) {
				$wpsc_feed_list = (array) get_option( 'wpsc_feed_list' );
				if ( count( $wpsc_feed_list ) <= 50 ) {
					$wpsc_feed_list[] = $dir . $meta_file;
					update_option( 'wpsc_feed_list', $wpsc_feed_list );
				}
			}
		}
	} else {
		wp_cache_debug( "Did not write meta file: meta-{$meta_file}\nsupercacheonly: $supercacheonly\nwp_cache_not_logged_in: $wp_cache_not_logged_in\nnew_cache:$new_cache" );
	}
	global $time_to_gc_cache;
	if( isset( $time_to_gc_cache ) && $time_to_gc_cache == 1 ) {
		wp_cache_debug( 'Executing wp_cache_gc action.', 3 );
		do_action( 'wp_cache_gc' );
	}
}