Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#24312 closed defect (bug) (worksforme)

wordpress 3.4.1 muti-sites image has not appear in time on safari sometimes

Reported by: ericdum's profile ericdum Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4.1
Component: Multisite Keywords: reporter-feedback
Focuses: Cc:


I'm running muti-sites wordpress with nginx, and test on safari (chrome is fine).

A very important thing is, the image is upload by administrator.

I found sometime some image has not appear immediately, I was just thing a about network trouble before, but I found the rule today.

the rule is:

enter the page, image shown.
refresh the page(Command + R), image disappeared.
refresh again, image shown.
again again, it disappeared.
NOTICE: disappeared is means that's not apear immediately: loaded the page about 2 second later, the image could be loaded.

When you refresh the page, safari send a image request to server with HTTP header HTTP_IF_NONE_MATCH and HTTP_IF_MODIFIED_SINCE.

Because of this is a mutiple site, nginx rewrite the request to ms-files.php to process it. ms-files.php found the image has not been modified, so it's response 304 with no content.

The bug is, the ms-files.php has already set Content-Length header before decided to response 304, so the response header going to be 304 with no content and Content-Length > 0. After that, safari was down.

Fixed the bug by add header( 'Content-Length: 0' ); to wp-includes/ms-files.php line 79.

     75 if ( ( $client_last_modified && $client_etag )
     76     ? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) )
     77     : ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) )
     78     ) {
     79     header( 'Content-Length: 0' );
     80     status_header( 304 ); // new line
     81     exit;
     82 }

Change History (3)

#1 @jeremyfelt
11 years ago

  • Keywords reporter-feedback added

Related #14730

Is the same issue present after upgrading to WordPress 3.6?

#3 @jeremyfelt
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

It does sound like adding Content-length could result in other side effects for browsers that don't expect that or Content-type on a 304. I was able to find a couple other mentions of Safari 5.0.x actually hanging when it was specified. I'd almost wonder if there's another issue here, maybe in the Nginx config?

Closing as worksforme. Feel free to reopen with more details on browser version.

Note: See TracTickets for help on using tickets.