Re: Patch for squid short expiration time

2006-07-31 Thread Henrik Nordstrom
mån 2006-07-31 klockan 11:25 +0200 skrev Eduard Veleba:

 the patch we sent you contains another one small change - possibility of 
 setting
 expiration time in refresh_pattern in seconds, not only minutes. It 
 simply doesn't
 multiply the time with 60, when there's letter 's' right after the 
 number. Is there
 any possibility to add this feature to squid?

Yes. See the discussion thread on squid-dev regarding this.

http://www.squid-cache.org/mail-archive/squid-dev/200607/0060.html

regards
Henrik


signature.asc
Description: Detta är en digitalt signerad	meddelandedel


Re: Patch for squid short expiration time

2006-07-30 Thread Michael Pye

Henrik Nordstrom wrote:

I am not very fond of the format. Would prefer

refresh_pattern min [unit] pct max [unit]


I was about to have a bash at this using strsep instead of strtok to 
parse the refresh_pattern as strsep allows you to test the next token as 
well as the current token. This way you can check for optional tokens 
like the units will be. strsep however is not as portable as strtok, 
it's not in solaris for example, so we would need to include a test for 
strsep and provide it if there is no system version. Does this seem 
reasonable ?


The code for calculating the seconds based on unit size is already in 
cache_cf.c function parseTimeUnits, so this bit should be fairly 
straight forward.


--
Michael


Re: Patch for squid short expiration time

2006-07-30 Thread Guido Serassio

Hi,

At 12.26 30/07/2006, Michael Pye wrote:


Henrik Nordstrom wrote:

I am not very fond of the format. Would prefer
refresh_pattern min [unit] pct max [unit]


I was about to have a bash at this using strsep instead of strtok to 
parse the refresh_pattern as strsep allows you to test the next 
token as well as the current token. This way you can check for 
optional tokens like the units will be. strsep however is not as 
portable as strtok, it's not in solaris for example, so we would 
need to include a test for strsep and provide it if there is no 
system version. Does this seem reasonable ?


An own strsep() used when there is no system version is already 
available in Squid 2.6 and Squid 3.0, so don't worry about it.


Regards

Guido



-

Guido Serassio
Acme Consulting S.r.l. - Microsoft Certified Partner
Via Lucia Savarino, 1   10098 - Rivoli (TO) - ITALY
Tel. : +39.011.9530135  Fax. : +39.011.9781115
Email: [EMAIL PROTECTED]
WWW: http://www.acmeconsulting.it/



Patch for squid short expiration time

2006-07-28 Thread Eduard Veleba

Dear Squid developers,

in our company Seznam.cz we use your application Squid for a long time, 
for example at our service http://wiki.mapy.cz,
and we are very satisfied with it. There was recently a demand to cache 
pages that has set expiration time shorter than
1 minute, that your system doesn´t allow. So we modified the code a 
little bit. This modification is an easy patch and we
would very appreciate if you use it in Squid for other users. The patch 
is sent as an attachment and it's patch for Debian

source squid 2.5.9-10sarge2.

Thank you in advance.
Eduard Veleba
Seznam.cz, a.s.

#! /bin/sh /usr/share/dpatch/dpatch-run
## 46-ntlm-scheme-assert.dpatch by Luigi Gangitano [EMAIL PROTECTED]
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad squid.2.5.9.orig/src/cache_cf.c squid-2.5.9/src/cache_cf.c
--- squid.2.5.9.orig/src/cache_cf.c 2006-07-27 15:17:25.0 +0200
+++ squid-2.5.9/src/cache_cf.c  2006-07-27 15:20:13.236439528 +0200
@@ -223,6 +223,27 @@
 return i;
 }
 
+int
+GetTimeInteger(void)
+{
+char *token = strtok(NULL, w_space);
+char *end;
+int i;
+double d;
+int mul = 60;
+if (token == NULL)
+   self_destruct();
+if (token[strlen(token) - 1] == 's') {
+mul = 1;
+token[strlen(token) - 1] = 0;
+}
+i = strtol(token, end, 0);
+d = strtod(token, NULL);
+if (d  INT_MAX || end == token)
+   self_destruct();
+return i * mul;
+}
+
 static squid_off_t
 GetOffT(void)
 {
@@ -1978,12 +1999,10 @@
 if (token == NULL)
self_destruct();
 pattern = xstrdup(token);
-i = GetInteger();  /* token: min */
-min = (time_t) (i * 60);   /* convert minutes to seconds */
-i = GetInteger();  /* token: pct */
+min = (time_t) GetTimeInteger();   /* token: min */
+i = GetInteger();  /* token: pct */
 pct = (double) i / 100.0;
-i = GetInteger();  /* token: max */
-max = (time_t) (i * 60);   /* convert minutes to seconds */
+max = (time_t) GetTimeInteger();   /* token: max */
 /* Options */
 while ((token = strtok(NULL, w_space)) != NULL) {
 #if HTTP_VIOLATIONS
diff -urNad squid.2.5.9.orig/src/cf.data.pre squid-2.5.9/src/cf.data.pre
--- squid.2.5.9.orig/src/cf.data.pre2006-07-27 15:17:24.0 +0200
+++ squid-2.5.9/src/cf.data.pre 2006-07-27 15:27:48.871315912 +0200
@@ -1615,6 +1615,12 @@
  -
 COMMENT_END
 
+NAME: expires_too_soon
+TYPE: int
+DEFAULT: 60
+LOC: Config.expiresTooSoon
+DOC_NONE
+
 NAME: wais_relay_host
 TYPE: string
 DEFAULT: none
diff -urNad squid.2.5.9.orig/src/refresh.c squid-2.5.9/src/refresh.c
--- squid.2.5.9.orig/src/refresh.c  2002-07-18 11:22:17.0 +0200
+++ squid-2.5.9/src/refresh.c   2006-07-27 15:31:45.515685944 +0200
@@ -331,7 +331,7 @@
  * 60 seconds delta, to avoid objects which expire almost
  * immediately, and which can't be refreshed.
  */
-int reason = refreshCheck(entry, NULL, 60);
+int reason = refreshCheck(entry, NULL, Config.expiresTooSoon);
 refreshCounts[rcStore].total++;
 refreshCounts[rcStore].status[reason]++;
 if (reason  200)
diff -urNad squid.2.5.9.orig/src/structs.h squid-2.5.9/src/structs.h
--- squid.2.5.9.orig/src/structs.h  2006-07-27 15:17:25.0 +0200
+++ squid-2.5.9/src/structs.h   2006-07-27 15:32:15.148181120 +0200
@@ -390,6 +390,7 @@
int lowWaterMark;
 } Swap;
 squid_off_t memMaxSize;
+int expiresTooSoon;
 struct {
char *relayHost;
u_short relayPort;


make-szn-squid.tar.gz
Description: application/gzip


Re: Patch for squid short expiration time

2006-07-28 Thread Henrik Nordstrom
fre 2006-07-28 klockan 10:55 +0200 skrev Eduard Veleba:
 Dear Squid developers,
 
 in our company Seznam.cz we use your application Squid for a long time, 
 for example at our service http://wiki.mapy.cz,
 and we are very satisfied with it. There was recently a demand to cache 
 pages that has set expiration time shorter than
 1 minute, that your system doesn´t allow. So we modified the code a 
 little bit. This modification is an easy patch and we
 would very appreciate if you use it in Squid for other users. The patch 
 is sent as an attachment and it's patch for Debian
 source squid 2.5.9-10sarge2.


Thanks, but we have already added a similar directive in squid-3.

NAME: minimum_expiry_time
COMMENT: (seconds)
TYPE: time_t
LOC: Config.minimum_expiry_time
DEFAULT: 60 seconds
DOC_START
The minimum caching time according to (Expires - Date)
Headers Squid honors if the object can't be revalidated
defaults to 60 seconds. In reverse proxy enorinments it
might be desirable to honor shorter object lifetimes. It
is most likely better to make your server return a
meaningful Last-Modified header however. In ESI environments
where page fragments often have short lifetimes, this will
often be best set to 0.
DOC_END

Regards
Henrik


signature.asc
Description: Detta är en digitalt signerad	meddelandedel


Re: Patch for squid short expiration time

2006-07-28 Thread Henrik Nordstrom
fre 2006-07-28 klockan 22:33 +0200 skrev Henrik Nordstrom:

  and we are very satisfied with it. There was recently a demand to cache 
  pages that has set expiration time shorter than
  1 minute, that your system doesn´t allow. So we modified the code a 

 Thanks, but we have already added a similar directive in squid-3.
 
 NAME: minimum_expiry_time

Now also backported to Squid-2.6.

Regards
Henrik


signature.asc
Description: Detta är en digitalt signerad	meddelandedel


Re: Patch for squid short expiration time

2006-07-28 Thread Michael Pye

Henrik Nordstrom wrote:

Now also backported to Squid-2.6.


Thanks for this addition. I had done something similar to Eduards 
modification in my caches.


However this backport doesn't allow you to specifiy the minimum refresh 
time in seconds. You may have a situation where you want the minimum 
refresh time to be 20 seconds, but still have some other 
refresh_patterns that use 40 seconds.


Would it be possible to add this ? Eduards patch seems to allow you to 
add an 's' after the minumum refresh time to indicate secconds so either 
this or another directive like minimum_refresh_seconds on could be 
used where seconds is assumed in refresh_pattern min times. I would be 
happy to submit something for that. As its a new feature however I guess 
it needs to go into squid3 first?


--
Michael



Re: Patch for squid short expiration time

2006-07-28 Thread Henrik Nordstrom
fre 2006-07-28 klockan 22:24 +0100 skrev Michael Pye:

 However this backport doesn't allow you to specifiy the minimum refresh 
 time in seconds. You may have a situation where you want the minimum 
 refresh time to be 20 seconds, but still have some other 
 refresh_patterns that use 40 seconds.

Right, that was what those parts was about... must be a bit tired..

 Would it be possible to add this?

Yes.

 Eduards patch seems to allow you to 
 add an 's' after the minumum refresh time to indicate secconds so either 
 this or another directive like minimum_refresh_seconds on could be 
 used where seconds is assumed in refresh_pattern min times. I would be 
 happy to submit something for that. As its a new feature however I guess 
 it needs to go into squid3 first?

Correct, but the code is basically the same in this area so there should
not be any issues porting the changes to squid3. You are welcome to give
it a shot.

Should be sufficient to just extend the refresh_pattern directive with
the ability to specify seconds. Internally it's seconds anyway as you
probably noticed, it's the config parser which translates from minutes
to seconds..

I am not very fond of the format. Would prefer

refresh_pattern min [unit] pct max [unit]

where unit is seconds/minutes/days, and defaults to minutes if not
specified. Makes the parser slightly more complex, but it's worth it I
think.

Regards
Henrik


signature.asc
Description: Detta är en digitalt signerad	meddelandedel