BP_Activity_Feed: http_headers ()

设置与Content-Type和浏览器缓存相关的各种HTTP头。

描述

该类方法的大部分派生自WP: send_headers ()

文件:bp-activity /类/ class-bp-activity-feed.php

protected function http_headers(){//如果不在目录页上,则设置一些额外的头文件//这是这样做的b/c BP使用伪页。如果(!Bp_is_directory()){全局$wp_query;wp_query - > is_404 = false;status_header (200);} //设置内容类型。@header('的content - type: text / xml;charset = '。Get_option ('blog_charset'), true);send_nosniff_header (); // Cache-related variables. $last_modified = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false ); $modified_timestamp = strtotime( $last_modified ); $etag = md5( $last_modified ); // Set cache-related headers. @header( 'Last-Modified: ' . $last_modified ); @header( 'Pragma: no-cache' ); @header( 'ETag: ' . '"' . $etag . '"' ); // First commit of BuddyPress! (Easter egg). @header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT'); // Get ETag from supported user agents. if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) { $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); // Remove quotes from ETag. $client_etag = trim( $client_etag, '"' ); // Strip suffixes from ETag if they exist (eg. "-gzip"). $etag_suffix_pos = strpos( $client_etag, '-' ); if ( ! empty( $etag_suffix_pos ) ) { $client_etag = substr( $client_etag, 0, $etag_suffix_pos ); } // No ETag found. } else { $client_etag = false; } // Get client last modified timestamp from supported user agents. $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; // Set 304 status if feed hasn't been updated since last fetch. if ( ( $client_last_modified && $client_etag ) ? ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) : ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) ) { $status = 304; } else { $status = false; } // If feed hasn't changed as reported by the user agent, set 304 status header. if ( ! empty( $status ) ) { status_header( $status ); // Cached response, so stop now! if ( $status == 304 ) { exit(); } } }

更新日志

更新日志
版本 描述
BuddyPress 1.9.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档,联络支持,或与我们联系销售团队