How to configure squid for retrieving (and caching) directly the static resources

amazon ec2apache-2.2cachereverse-proxysquid

I have an Apache/Tomcat/Spring tc Server running on CentOS EC2 VM.

I would like to install squid on the same machine as a proxy for retrieving (directly i.e. without forwarding the request to Apache/Tomcat) and caching static content ONLY identified by URIs : /images, /css or /js.

Other URIs should be forwarded to the normal Web Server and not cached.

Since I am a newbie, I didn't find from squid documentation how to configure squid for this desired behavior (and if it is even possible).

Could you please help me and tell me how should I configure squid for this purpose?

Thank you.

Best Answer

By default, it will cache all static content, the predicate

hierarchy_stoplist cgi-bin ?

Is on by default, and is designed to prevent dynamic pages from being cached.

You can create an acl like the following:

acl static_content urlpath_regex ^/images
acl static_content urlpath_regex ^/css
acl static_content urlpath_regex ^/js

Then apply like this:

no_cache deny !static_content

Not tested..