Uploaded image for project: 'Traffic Control'
  1. Traffic Control
  2. TC-309

No Cache-Control on images

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • None
    • None
    • Traffic Ops

    Description

      From GH issue #962:

      This was observed during 1.3.0RC6 testing. The headers are different in 1.1.6 (actually not cache-control headers).

      Images didn't show up sometimes, high latency to display the Health->Table View.

      Is this a byproduct of using localhost connection (through Vagrant) ?

      But doesn't seems like this code changed along the way...

      Request URL:https://127.0.0.1:4443/images/graph.png
      Request Method:GET
      Status Code:200 OK
      
      Remote Address:127.0.0.1:4443
      Response Headers
      view source
      Accept-Ranges:bytes
      Access-Control-Allow-Credentials:true
      Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept
      Access-Control-Allow-Methods:POST,GET,OPTIONS,PUT,DELETE
      Access-Control-Allow-Origin:http://localhost:8080
      Cache-Control:no-cache, no-store, max-age=0, must-revalidate
      Connection:keep-alive
      Content-Length:892
      Content-Type:image/png
      Date:Fri, 22 Jan 2016 15:03:36 GMT
      Last-Modified:Fri, 22 Jan 2016 13:14:28 GMT
      Server:Mojolicious (Perl)
      

      Logs

      10.0.2.2 - - [22/Jan/2016:15:11:55 +0000] "GET /api/1.1/traffic_monitor/stats.json?data_type=json HTTP/1.1" 200 73
      10.0.2.2 - - [22/Jan/2016:15:11:55 +0000] "GET /images/good.png HTTP/1.1" 200 617
      10.0.2.2 - - [22/Jan/2016:15:11:55 +0000] "GET /images/graph.png HTTP/1.1" 200 892
      10.0.2.2 - - [22/Jan/2016:15:12:00 +0000] "GET /api/1.1/traffic_monitor/stats.json?data_type=json HTTP/1.1" 200 73
      10.0.2.2 - - [22/Jan/2016:15:12:02 +0000] "GET /api/1.1/traffic_monitor/stats.json?data_type=json HTTP/1.1" 200 73
      10.0.2.2 - - [22/Jan/2016:15:12:02 +0000] "GET /images/good.png HTTP/1.1" 200 617
      10.0.2.2 - - [22/Jan/2016:15:12:02 +0000] "GET /images/graph.png HTTP/1.1" 200 892
      

      By default, the cdn.conf contains an entry showing

        cors => {
          access_control_allow_origin => 'http://localhost:8080'
        },
      

      Comment those lines and this will disable the Cache-Control headers for all files. Use only if you are not going through a proxy. Enjoy the fast UI again.

      The Cache Control should be changed for static files. These should probably be set to something like max-age=86400. When doing development, these should be disabled so one doesn't get frustrated not seeing updates made...

      /opt/traffic_ops/app/public/css
      /opt/traffic_ops/app/public/images
      /opt/traffic_ops/app/public/js
      /opt/traffic_ops/app/public/theme
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            smalenfant Steve Malenfant
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: