]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/store/id_rewriters/file/storeid_file_rewrite.pl.in
11 storeid_file_rewrite - File based Store-ID helper for Squid
15 storeid_file_rewrite filepath
19 This program acts as a store_id helper program, rewriting URLs passed
20 by Squid into storage-ids that can be used to achieve better caching
21 for websites that use different URLs for the same content.
23 It takes a text file with two tab separated columns.
24 Column 1: Regular expression to match against the URL
25 Column 2: Rewrite rule to generate a Store-ID
27 ^http:\/\/[^\.]+\.dl\.sourceforge\.net\/(.*) http://dl.sourceforge.net.squid.internal/$1
29 Rewrite rules are matched in the same order as they appear in the rules file.
30 So for best performance, sort it in order of frequency of occurrence.
32 This program will automatically detect the existence of a concurrency channel-ID and adjust appropriately.
33 It may be used with any value 0 or above for the store_id_children concurrency= parameter.
37 The only command line parameter this helper takes is the regex rules file name.
41 This program and documentation was written by I<Alan Mizrahi <alan@mizrahi.com.ve>>
43 Based on prior work by I<Eliezer Croitoru <eliezer@ngtech.co.il>>
47 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
49 * Squid software is distributed under GPLv2+ license and includes
50 * contributions from numerous individuals and organizations.
51 * Please see the COPYING and CONTRIBUTORS files for details.
53 Copyright (C) 2013 Alan Mizrahi <alan@mizrahi.com.ve>
54 Based on code from Eliezer Croitoru <eliezer@ngtech.co.il>
56 This program is free software; you can redistribute it and/or modify
57 it under the terms of the GNU General Public License as published by
58 the Free Software Foundation; either version 2 of the License, or
59 (at your option) any later version.
61 This program is distributed in the hope that it will be useful,
62 but WITHOUT ANY WARRANTY; without even the implied warranty of
63 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64 GNU General Public License for more details.
66 You should have received a copy of the GNU General Public License
67 along with this program; if not, write to the Free Software
68 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
72 Questions on the usage of this program can be sent to the I<Squid Users mailing list <squid-users@lists.squid-cache.org>>
76 Bug reports need to be made in English.
77 See http://wiki.squid-cache.org/SquidFaq/BugReporting for details of what you need to include with your bug report.
79 Report bugs or bug fixes using http://bugs.squid-cache.org/
81 Report serious security bugs to I<Squid Bugs <squid-bugs@lists.squid-cache.org>>
83 Report ideas for new improvements to the I<Squid Developers mailing list <squid-dev@lists.squid-cache.org>>
89 The Squid wiki http://wiki.squid-cache.org/Features/StoreID
91 The Squid Configuration Manual http://www.squid-cache.org/Doc/config/
95 my @rules; # array of [regex, replacement string]
97 die "Usage: $0 <rewrite-file>\n" unless $#ARGV == 0;
100 open RULES
, $ARGV[0] or die "Error opening $ARGV[0]: $!";
104 if (/^\s*([^\t]+?)\s*\t+\s*([^\t]+?)\s*$/) {
105 push(@rules, [qr/$1/, $2]);
107 print STDERR
"$0: Parse error in $ARGV[0] (line $.)\n";
113 # read urls from squid and do the replacement
114 URL
: while (<STDIN
>) {
116 last if $_ eq 'quit';
119 if (s/^(\d+\s+)//o) {
123 foreach my $rule (@rules) {
124 if (my @match = /$rule->[0]/) {
127 for (my $i=1; $i<=scalar(@match); $i++) {
128 s/\$$i/$match[$i-1]/g;
130 print $channel, "OK store-id=$_\n";
134 print $channel, "ERR\n";