Squid cannot cache static files with query string

The default configuration of Squid is to not cache dynamic content (which URLs with query strings are considered to be). That Squid wiki page explains how to change this. Basically you need to remove the following line from squid.conf:

cache deny QUERY

and replace it with these refresh patterns:

refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern .            0 20% 4320