Tapestry
  1. Tapestry
  2. TAPESTRY-955

Expires header not set correctly in AssetService

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.1
    • Fix Version/s: 4.1
    • Component/s: Framework
    • Labels:
      None

      Description

      The AssetService sets the Expires header to control caching. The duration is calculated by the following lines of code:

      /**

      • Time vended assets expire. Since a change in asset content is a change in asset URI, we want
      • them to not expire ... but a year will do.
        */
        private final long _expireTime = _startupTime + 365 * 24 * 60 * 60 * 1000;

      However, this causes a numeric overflow, resulting in an expiry in the order of about a month instead of a year. This means that browser clients will start issuing (unnecessary) conditional requests about a month after a Tapestry application is deployed, leading to unnecessary overhead.

      The correct code is:

      private final long _expireTime = _startupTime + 365 * 24 * 60 * 60 * 1000L;

      (notice the final "L"). However, I'd argue to make the period longer, for example 10 years:

      private final long _expireTime = _startupTime + 10 * 365 * 24 * 60 * 60 * 1000L;

      Regards,

      Marcel

        Activity

        Marcel Juffermans created issue -
        Jesse Kuhnert made changes -
        Field Original Value New Value
        Assignee Jesse Kuhnert [ jkuhnert ]
        Jesse Kuhnert made changes -
        Resolution Fixed [ 1 ]
        Fix Version/s 4.1 [ 12310632 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Mark Thomas made changes -
        Workflow jira [ 12372236 ] Default workflow, editable Closed status [ 12567764 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12567764 ] jira [ 12590892 ]

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Marcel Juffermans
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development