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

Plugin resource servlet does not provide headers necessary for caching

      It appears that files pulled from a resource don't cache properly in the browser so they get loaded over and over and over...

      Here's an example:

      Response Headers - http://www.randombits.org/download/resources/com.adaptavist.confluence.themes.sitebuilder:sitebuilder/icons/document_plain.png

      Date: Wed, 01 Feb 2006 05:52:20 GMT
      Server: Resin/3.0.14
      Content-Type: image/png
      Transfer-Encoding: chunked

      200 OK

      As you can see, the HTTP header is sparse to say the least.

      Here's an example of an image pulled from a normal web server:

      Response Headers - http://adaptavist.com/glyphs/about.png

      Date: Wed, 01 Feb 2006 06:09:46 GMT
      Server: Apache/1.3.29 (Unix) mod_become/1.3 DAV/1.0.3 mod_perl/1.29 PHP/4.3.9 mod_fastcgi/2.4.2
      Last-Modified: Thu, 11 Aug 2005 16:28:48 GMT
      Etag: "50b29b-30e-42fb7cc0"
      Accept-Ranges: bytes
      Content-Length: 782
      Content-Type: image/png

      200 OK

      As you can see, there are certain things in the header that would certainly help with caching:

      • Last-Modified - allow browser to know if it has the correct version of the file
      • Content-Length - allow browser to know if the file is the same size
      • Etag - allows the browser to check it's got the same entity reference

      Then there is the chunked transfer encoding output from the resource URL - I'm just guessing here, but that's going to make it very difficult indeed for the browser to work out if it has the latest file or not? Pretend to be a web browser for a minute, and decide if you'd want to work out if you already had a chunked file cached or not:

      http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1

      I don't know which of these things, if any, would actually alter caching, but it seems that if the HTTP headers from resources could be "fleshed out" a little to give some extra information, there would be a higher chance of the browser caching resources.

      So, my question is: Can we output additional HTTP headers AND can we have them sent non-chunked?

      Without these two vital things, pulling files from resources is going to be slooooowwww. As a growing number of plugins are using resources in this way (images, css, javascript, etc), we're going to see Confluence sites using lots of plugins getting slower and slower.

      If the servlet that sends out the files uses the jar's date as the Last-Modified and also sends the file normally and puts it's Content-Length on, things should run a lot quicker for all resources pulled from plugins, ie. a Confluence-level optimisation. Of course, there may be times when a resource needs a different date (eg. dynamically created resources) so there would have to be a way to define this. From my understanding, however, resources that are simply pulled form the jar (ie. a file in the jar) will never be dynamic?

      David Peterson will no doubt be along shortly to add to this (eg. the idea about dumping the files on to disk so they can be pulled more easily without needing to go in to the jar each time)...

          Form Name

            [CONFSERVER-5418] Plugin resource servlet does not provide headers necessary for caching

            I've rolled this fix into Confluence 2.2 (atlassian-plugins-0.3.22)

            Thanks, guys!

            Charles Miller (Inactive) added a comment - I've rolled this fix into Confluence 2.2 (atlassian-plugins-0.3.22) Thanks, guys!

            Guy Fraser [Adaptavist.com] added a comment - Here it is: http://confluence.atlassian.com/display/DISC/Confluence+Patch+-+Adding+Modification+Headers+to+Plugins+Downloadable+Resources

            jens added a comment -

            Thanks for the info Guy.

            This will be awesome for macros requiring lots of JavaScript like the dynamic task-list.

            jens added a comment - Thanks for the info Guy. This will be awesome for macros requiring lots of JavaScript like the dynamic task-list.

            Dan gave me a preview of two Confluence installs earlier this evening - one with his patch for the resource servlet, and one without. With "Fasterfox" set to default speed settings, the patched version was twice as fast! Similar performance increases were seen on Internet Exploder and Opera also

            Hopefully we'll be able to patch our hosted clients within the next 48 hours or so and we'll certainly be contributing the code back to the community as it really does speed up the performance of plugins that pull assets from the resources servlet (much more than I had expected or hoped for).

            Bear in mind that this applies not just to graphics, but javascript files, css files, etc. Cached resources here we come! Yay!

            Guy Fraser [Adaptavist.com] added a comment - Dan gave me a preview of two Confluence installs earlier this evening - one with his patch for the resource servlet, and one without. With "Fasterfox" set to default speed settings, the patched version was twice as fast! Similar performance increases were seen on Internet Exploder and Opera also Hopefully we'll be able to patch our hosted clients within the next 48 hours or so and we'll certainly be contributing the code back to the community as it really does speed up the performance of plugins that pull assets from the resources servlet (much more than I had expected or hoped for). Bear in mind that this applies not just to graphics, but javascript files, css files, etc. Cached resources here we come! Yay!

            jens added a comment -

            Hi Guy,

            We will consider to release a DR [1] next week, based on our progress. Please note that this will be a DR and might not be as stable as the final release. Since 2.0 we haven't had any Developer Releases so it is actually a good idea to provide one if it proves useful for you.

            Cheers,
            Jens

            [1] http://confluence.atlassian.com/display/DOC/Development+Releases

            jens added a comment - Hi Guy, We will consider to release a DR [1] next week, based on our progress. Please note that this will be a DR and might not be as stable as the final release. Since 2.0 we haven't had any Developer Releases so it is actually a good idea to provide one if it proves useful for you. Cheers, Jens [1] http://confluence.atlassian.com/display/DOC/Development+Releases

            Hi Charles,

            Would it be possible for us to get hold of a Confluence 2.2 before the general release - we've got lots of clients who are "chomping at the bit" for the improved performance this will offer so we'd like to test Builder and our other visual macros prior to release rather than have a flood of bugs reported when people suddenly start upgrading ahead of us. We are also aware that it won't be a magic bullet for all performance issues, so we're keen to set client expectations about the performance boost and provide them with tips for making their home page faster (eg. don't flood it with a gazillion graphical plugins like we do hehe).

            FYI: We're drooling over some of the additional features and bug fixes in 2.2, especially from a plugin development point of view

            Guy

            Guy Fraser [Adaptavist.com] added a comment - Hi Charles, Would it be possible for us to get hold of a Confluence 2.2 before the general release - we've got lots of clients who are "chomping at the bit" for the improved performance this will offer so we'd like to test Builder and our other visual macros prior to release rather than have a flood of bugs reported when people suddenly start upgrading ahead of us. We are also aware that it won't be a magic bullet for all performance issues, so we're keen to set client expectations about the performance boost and provide them with tips for making their home page faster (eg. don't flood it with a gazillion graphical plugins like we do hehe). FYI: We're drooling over some of the additional features and bug fixes in 2.2, especially from a plugin development point of view Guy

            The hacky way would be fine for now (and probably long term IMHO) - just reset the date each time a plugin is installed, etc., as you say

            Guy Fraser [Adaptavist.com] added a comment - The hacky way would be fine for now (and probably long term IMHO) - just reset the date each time a plugin is installed, etc., as you say

            To implement this correctly, the plugin subsystem would need to know when each plugin was last modified. We could then use that for the modification date header.

            To implement this hackily, we could just keep the same last-modified time for all plugin resources, and reset it whenever any plugin is enabled/disabled/installed/uninstalled.

            Charles Miller (Inactive) added a comment - To implement this correctly, the plugin subsystem would need to know when each plugin was last modified. We could then use that for the modification date header. To implement this hackily, we could just keep the same last-modified time for all plugin resources, and reset it whenever any plugin is enabled/disabled/installed/uninstalled.

            The JavaPolis 2006 confluence site would like to use the Adaptavist builder theme (like we're doing for SpringOne.com site)
            but if the plugins are not cached we might be forced not to use it because of the response delay of the confluence plugins
            So please, please make sure you can fix this in the next release of Confluence !!

            Thanks in advance,
            Stephan

            Stephan Janssen added a comment - The JavaPolis 2006 confluence site would like to use the Adaptavist builder theme (like we're doing for SpringOne.com site) but if the plugins are not cached we might be forced not to use it because of the response delay of the confluence plugins So please, please make sure you can fix this in the next release of Confluence !! Thanks in advance, Stephan

            We've got some clients who are having problems due to this issue as their sites are viewed via modem - in such cases reloading even the smallest file repeatedly causes massive delays.

            So yes, if the priority could be icreased a little it would be most appreciated.

            Guy Fraser [Adaptavist.com] added a comment - We've got some clients who are having problems due to this issue as their sites are viewed via modem - in such cases reloading even the smallest file repeatedly causes massive delays. So yes, if the priority could be icreased a little it would be most appreciated.

              Unassigned Unassigned
              matt@atlassian.com Matt Ryall
              Affected customers:
              28 This affects my team
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: