Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

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


  • 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'}})

  1. Henning Kiel says:

    Regarding the caching header question: This post 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.



  2. Tom Cocca says:

    I have been successful with mod_rewrite when doing things like:

    RewriteCond {query_string} Title=SomeTitle
    RerwriteRule (/old_title_page*) [R=301,L]

    so I can rescue and redirect to

    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

  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:

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

  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’.

  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.

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

    tell application “Google Chrome”
    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”

  7. Obviously I mean AppleScript, not ActionScript

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *