Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Tools
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Standup 7/1/10 – Caching Apache images that have ?123456789

David Goudreau
Thursday, July 1, 2010

Help

  • Does anyone know how to set a caching header for urls that end with a cachebusting string (e.g. ?123456789)? Apparently you’re not allowed to get the query string when mucking with rewrite rules. A couple of people think that you are able to get your hands on it…somehow.
  • How do you do a screen capture from the Mac command line? We want to do a screen capture of a running emulator. Maybe something like this?

Interesting Things

  • Rails 2.3.8 – for nested attributes, ‘_destroy’ is the new ‘_delete’. Looks like the Rails team is on top of it. Use

    @foo.update_attributes(:foo_attributes => {'0' => {:id => '1',  '_destroy' => '1'}})
    

    instead of

    @foo.update_attributes(:foo_attributes => {'0' => {:id => '1',  '_delete' => '1'}})
    
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

7 Comments

  1. Henning Kiel says:

    Regarding the caching header question: This post http://www.stephensykes.com/blog_perm.html?157 explains a nice trick.

    You basically create a symbolic link inside the directory with your assets, pointing to the same asset directory. You then can create a rewrite rule matching the cache busting query string and rewrite it to that symlink. Then you just create a special location in apache for the symlink which adds the correct expires headers.

    Cheers,

    Henning

    July 1, 2010 at 1:08 pm

  2. Tom Cocca says:

    I have been successful with mod_rewrite when doing things like:

    RewriteCond {query_string} Title=SomeTitle
    RerwriteRule (/old_title_page*) http://www.domain.com/some_title? [R=301,L]

    so I can rescue http://www.domain.com/old_title_page?Title=SomeTitle and redirect to http://www.domain.com/some_title

    Not sure if it will help at all with your caching issue but might help finding out how to get access to the querystring on the url…

    For screen capture check out the webkit2png project – it looks really interesting. Implemented in python though …

    ~ Tom

    July 1, 2010 at 1:48 pm

  3. Cody Caughlan says:

    I use this Apache config rule to set far-future expires for static assets.


    # Set far future expires
    RewriteEngine on
    RewriteCond %{REQUEST_URI} .(css|js|jpe?g|png|gif|ico) [NC]
    RewriteCond %{QUERY_STRING} [0-9]+$
    RewriteRule ^(.*)$ $1 [E=VERSIONED_FILE:1,L]
    Header add “Expires” “Mon, 28 Jul 2014 23:30:00 GMT” env=VERSIONED_FILE
    Header add “Cache-Control” “max-age=315360000″ env=VERSIONED_FILE
    Header unset ETag
    FileETag None

    Also available here if the above gets munged:
    http://gist.github.com/460556

    One caveat is that you have to hardcode the expires date in this config – so come 2014 it will need to be updated.

    July 1, 2010 at 2:02 pm

  4. Jonathan says:

    Screen capture is easy: Cmd-Shift-4 will change the cursor to crosshairs so that you can drag out a box to be saved to a file on your desktop.

    If you want the whole desktop, try Cmd-Shift-3.

    For more details, go to Help menu and search for ‘Shortcuts for taking pictures of the screen’.

    July 1, 2010 at 5:19 pm

  5. Tyler Schultz says:

    I asked this mornings screen capture question – I didn’t make myself clear. We’re trying to get an image capture of a window (an emulator window) so we can incorporate the image into tests. We were hoping to do this on our CI machine, necessitating a programmatic approach.

    Xian whipped up an applescript that hides all windows except for the emulator, moves the emulator to the upper left corner, and then fires the screencapture command. This all works fine, but we were hoping to capture only the emulator window and not the entire screen. Unfortunately, the screencapture command does not appear to support capturing only a window.

    July 1, 2010 at 10:08 pm

  6. Duncan Beevers says:

    Here’s a simple example banged out in ActionScript for capturing a single window

    tell application “Google Chrome”
    activate
    set bounds of window 1 to {1, 1, 800, 600}
    do shell script “screencapture -x capture.png”
    do shell script “mogrify -crop 800×600+1+22 capture.png”
    end

    July 2, 2010 at 7:08 pm

  7. Duncan Beevers says:

    Obviously I mean AppleScript, not ActionScript

    July 2, 2010 at 7:09 pm

Add New Comment Cancel reply

Your email address will not be published.

David Goudreau

David Goudreau
San Francisco

Recent Posts

  • Standup 4/1/2011: April Fool's edition
  • Standup 3/31/2011: Process.spawn pwns all yer codez!
  • Standup 3/29/2011: Git it!
Subscribe to David's Feed

Author Topics

agile (14)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Tools
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >