Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.