Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-11325

Refreshing a page hangs and corrupts page results when a custom logo is used on Confluence running behind mod_jk or mod_proxy_ajp

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: High High
    • 2.8.1
    • None
    • None

      Patch for 2.6.x, 2.7.x, 2.8.0

      Place attached ResourceDownload.class in confluence/WEB-INF/lib/confluence-2.x.x.jar/com/atlassian/confluence/servlet/download

      This affects people when:

      • A custom logo is set (eg. in Administration -> Global Logo).
      • The server has HTTP keepalives enabled (usually the case)
      • You refresh (eg. ctrl-r in Firefox) a page

      Then the page load may hang halfway for around 15 seconds, and there may be odd visual problems as if a stylesheet is broken.

      The problem is that Confluence is trying to enable browser caching, by sending the logo with a "304 Not Modified" header. Unfortunately it is also sending the image body in the response. According to RFC2616 §10.3.5 "The 304 response MUST NOT contain a message-body". Confluence does. This then causes varying effects:

      • If you're serving requests directly from Tomcat's HTTP connector ("Server: Apache-Coyote/1.1" in the HTTP response), everything appears fine. Evidently Tomcat is stripping the bogus body for you:
        jturner@psyche:~$ HEAD 'http://localhost:8081/confluence/download/userResources/logo' | grep ETag
        ETag: "1207190442000"
        jturner@psyche:~$ ETAG="1207190442000"
        jturner@psyche:~$ echo -e "GET /confluence/download/userResources/logo HTTP/1.1\nHost: localhost:8081\nIf-None-Match: \"${ETAG}\"\n" | nc localhost 8081
        HTTP/1.1 304 Not Modified
        Server: Apache-Coyote/1.1
        X-Confluence-Request-Time: 1207191596513
        Last-Modified: Thu, 03 Apr 2008 02:40:42 GMT
        ETag: "1207190442000"
        Date: Thu, 03 Apr 2008 02:59:56 GMT
        
        
      • If you're running Tomcat behind mod_jk or mod_proxy_ajp, then the browser sees the "304 Not Modified" header, plus the body that shouldn't be there:
        jturner@psyche:~$ HEAD 'http://localhost/confluence/download/userResources/logo' | grep ETag
        ETag: "1207190442000"
        jturner@psyche:~$ ETAG="1207190442000"
        jturner@psyche:~$ echo -e "GET /confluence/download/userResources/logo HTTP/1.1\nHost: localhost\nIf-None-Match: \"${ETAG}\"\n" | nc localhost 80
        HTTP/1.1 304 Not Modified
        Date: Thu, 03 Apr 2008 03:01:17 GMT
        Server: Apache/2.2.3 (Ubuntu) DAV/2 mod_jk/1.2.18 mod_ssl/2.2.3 OpenSSL/0.9.8c
        ETag: "1207190442000"
        
        �PNGIHDR��a�d�IT    pHYs..........
        

      By taking a TCP dump of its interactions with the server:

      jturner@psyche:~$ sudo tcpdump -i lo -s 1500 -w port80.pcap "host localhost and port 80"
      tcpdump: listening on lo, link-type EN10MB (Ethernet), capture size 1500 bytes
      110 packets captured
      220 packets received by filter
      0 packets dropped by kernel
      jturner@psyche:~$ 
      

      you can see a 15s delay, and the response to the logo request will often have headers after the body content.

        1. logo.png
          logo.png
          5 kB
        2. ResourceDownload.class
          4 kB

            [CONFSERVER-11325] Refreshing a page hangs and corrupts page results when a custom logo is used on Confluence running behind mod_jk or mod_proxy_ajp

            I am reviewing this and will reply back shortly.

            Kristopher Dames
            Contegix LLC
            Beyond Managed Hosting(r) for Your Enterprise

            Contegix Support added a comment - I am reviewing this and will reply back shortly. Kristopher Dames Contegix LLC Beyond Managed Hosting(r) for Your Enterprise

            On OS X you'll need to use lwp-request -m HEAD instead of HEAD, similar for GET.

            Dan Hardiker added a comment - On OS X you'll need to use lwp-request -m HEAD instead of HEAD , similar for GET.

            Patch for 2.6.x, 2.7.x, 2.8.0

            Place attached ResourceDownload.class in confluence/WEB-INF/lib/confluence-2.x.x.jar/com/atlassian/confluence/servlet/download

            Chris Broadfoot [Atlassian] added a comment - - edited Patch for 2.6.x, 2.7.x, 2.8.0 Place attached ResourceDownload.class in confluence/WEB-INF/lib/confluence-2.x.x.jar/com/atlassian/confluence/servlet/download

            Are there any patches for Confluence 2.7.x? Conf 2.8 seems pretty slow (as can be seen on confluence.atlassian.com)...

            Guy Fraser [Adaptavist.com] added a comment - Are there any patches for Confluence 2.7.x? Conf 2.8 seems pretty slow (as can be seen on confluence.atlassian.com)...

            Resource requests that return HTTP 304 should now have empty response bodies.

            Chris Broadfoot [Atlassian] added a comment - Resource requests that return HTTP 304 should now have empty response bodies.

            To illustrate that extranet JIRA (2.8-rc1) also has this problem, first find your JSESSIONID from the browser:

            $ JSID="6D969B4926113BCE3377BDB9EED42100.ajp13-ext-2"
            

            Use it to find the logo's ETag:

            $ HEAD -H "Cookie: JSESSIONID=${JSID}" http://extranet.atlassian.com/download/userResources/TEST/logo | grep ET
            ETag: "1207188629000"
            

            Then send a request that returns a 304 response:

            $ ETAG="1207188629000"
            $ echo -e "GET /download/userResources/TEST/logo HTTP/1.1\nHost: extranet.atlassian.com\nCookie: JSESSIONID=${JSID}\nIf-None-Match: \"${ETAG}\"\n" | nc extranet.atlassian.com 80
            HTTP/1.1 304 Not Modified
            Date: Thu, 03 Apr 2008 03:35:08 GMT
            Server: Apache/2.2.6 (Red Hat)
            ETag: "1207188629000"
            
            ���JFIF��C��C�00.....
            

            Note the body that shouldn't be there.

            Note: disabling GZip compression in Confluence does not help. This bug is similar in mechanism and effect to GZIPFILTER-5, although the cause is different).

            Jeff Turner added a comment - To illustrate that extranet JIRA (2.8-rc1) also has this problem, first find your JSESSIONID from the browser: $ JSID="6D969B4926113BCE3377BDB9EED42100.ajp13-ext-2" Use it to find the logo's ETag: $ HEAD -H "Cookie: JSESSIONID=${JSID}" http://extranet.atlassian.com/download/userResources/TEST/logo | grep ET ETag: "1207188629000" Then send a request that returns a 304 response: $ ETAG="1207188629000" $ echo -e "GET /download/userResources/TEST/logo HTTP/1.1\nHost: extranet.atlassian.com\nCookie: JSESSIONID=${JSID}\nIf-None-Match: \"${ETAG}\"\n" | nc extranet.atlassian.com 80 HTTP/1.1 304 Not Modified Date: Thu, 03 Apr 2008 03:35:08 GMT Server: Apache/2.2.6 (Red Hat) ETag: "1207188629000" ���JFIF��C��C�00..... Note the body that shouldn't be there. Note: disabling GZip compression in Confluence does not help. This bug is similar in mechanism and effect to GZIPFILTER-5, although the cause is different).

              cbroadfoot Chris Broadfoot [Atlassian]
              7ee5c68a815f Jeff Turner
              Affected customers:
              1 This affects my team
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: