squid: Add RAM-only Proxy functionality
Commit Message
As suggested by Oliver "giller" Fieker <oli@new-lan.de>
in bug 10592 I added the functionality to use the squid as ram-only cache.
Further it defines the maximum_object_size_in_memory
as 2% of the in the webif defined "Memory cache size".
The maximum_object_size_in_memory should have a useful
size of the defined memory cache and I don't want to
create another variable which muste be fulled in by the user.
Signed-off-by: Daniel Weismüller <daniel.weismueller@ipfire.org>
Suggested-by: Oliver "giller" Fieker <oli@new-lan.de>
Suggested-by: Kim Wölfel <xaver4all@gmx.de>
Acked-by: Michael Tremer <michael.tremer@ipfire.org>
Cc: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Daniel Weismüller <daniel.weismueller@ipfire.org>
---
html/cgi-bin/proxy.cgi | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
@@ -401,8 +401,7 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
$errormessage = $Lang::tr{'proxy errmsg filedescriptors'};
goto ERROR;
}
- if (!($proxysettings{'CACHE_MEM'} =~ /^\d+/) ||
- ($proxysettings{'CACHE_MEM'} < 1))
+ if (!($proxysettings{'CACHE_MEM'} =~ /^\d+/))
{
$errormessage = $Lang::tr{'advproxy errmsg mem cache size'};
goto ERROR;
@@ -3174,7 +3173,7 @@ END
}
}
- if ($proxysettings{'CACHE_SIZE'} > 0)
+ if (($proxysettings{'CACHE_SIZE'} > 0) || ($proxysettings{'CACHE_MEM'} > 0))
{
print FILE "\n";
@@ -3271,7 +3270,12 @@ cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} $proxysettings{'L1_DI
END
;
} else {
- print FILE "cache deny all\n\n";
+ if ($proxysettings{'CACHE_MEM'} > 0) {
+ # always 2% of CACHE_MEM defined as max object size
+ print FILE "maximum_object_size_in_memory " . int($proxysettings{'CACHE_MEM'} * 1024 * 0.02) . " KB\n\n";
+ } else {
+ print FILE "cache deny all\n\n";
+ }
}
print FILE <<END