Mfswiggs
Mfswiggs

Reputation: 347

Squid only cache content for a specific domain and file type.

I want to setup Squid to cache specific files (.jpeg) from a specific domain. These files are updated daily. I'm running Ubuntu. I have a script on my laptop that makes use of these files and ideally I would like this script to make calls to the Squid cache instead of directly to the server. I don't want to cache content that is not from the domain and is not of the correct file type. Is this possible, and what do I need to edit in squid.conf ?

Upvotes: 4

Views: 5714

Answers (2)

Bart Polot
Bart Polot

Reputation: 61

The proposed solution:

acl filecachetype urlpath_regex \.jpeg
acl cacheDomain dstdomain <your domainname> or acl cacheDomain dst <domain ip>
cache deny !filecachetype !cacheDomain 

Will not work. ACLs do AND on the same like so it means that it will only avoid caching when a file is both non-jpeg and not on domain.com. It will still cache:

  • all files on <your domain>
  • all jpeg files on any domain

What you need is:

acl filecachetype urlpath_regex \.jpeg
acl cacheDomain dstdomain <your domainname>
cache deny !filecachetype
cache deny !cacheDomain

This will deny caching files that are not jpeg (no matter where they are, even on your server) and also will deny caching files not on <your domain> (even if they are jpeg). Logical OR, instead of AND.

Upvotes: 3

Share_Improve
Share_Improve

Reputation: 447

acl filecachetype urlpath_regex \.jpeg
acl cacheDomain dstdomain <your domainname> or acl cacheDomain dst <domain ip>
cache deny !filecachetype !cacheDomain 
cache all

Upvotes: 1

Related Questions