GNU bug report logs - #49033
28.0.50; [PATCH] Feature suggestion, url-cache-expiry-alist to override expire time for cache pruning

Previous Next

Package: emacs;

Reported by: Alex Bochannek <alex <at> bochannek.com>

Date: Tue, 15 Jun 2021 05:41:01 UTC

Severity: wishlist

Found in version 28.0.50

To reply to this bug, email your comments to 49033 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Tue, 15 Jun 2021 05:41:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alex Bochannek <alex <at> bochannek.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 15 Jun 2021 05:41:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alex Bochannek <alex <at> bochannek.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; [PATCH] Feature suggestion, url-cache-expiry-alist to
 override expire time for cache pruning
Date: Mon, 14 Jun 2021 22:40:29 -0700
[Message part 1 (text/plain, inline)]
Hello!

I was looking at the Gravatar code and noticed Larsi's change last year
to disable the URL caching and instead use a hash table. I would like to
see the timeout for the hash table configurable again and this sent me
to the `url-cache-expired' and `url-cache-prune-cache' functions. It
appears that `url-cache-expired' is no longer used after the Gravatar
caching change, so I was wondering if maybe it could be useful to have a
more general, URL-specific expiry policy in the URL caching code. This
way, on-disk caching for, e.g., gravatar.com could be longer than for
the in-memory hash - right now expiry for the Gravatar memory cache is
12 hours, for the global disk cache it is 1 hour.

I wrote up the below and I am asking for feedback on it. I was
particularly concerned about back-forming the URL based on the cache
path and there really should be some test cases around that. I have done
minimal testing and I am open to suggestions to do this differently.
[Message part 2 (text/x-patch, inline)]
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index 830e6ba9dc..1bf5abcb51 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -38,6 +38,12 @@ url-cache-expire-time
   :type 'integer
   :group 'url-cache)
 
+(defcustom url-cache-expiry-alist nil
+  "Alist of URL regular expressions to override the `url-cache-expire-time'."
+  :version "28.1"
+  :type 'alist
+  :group 'url-cache)
+
 ;; Cache manager
 (defun url-cache-file-writable-p (file)
   "Follows the documentation of `file-writable-p', unlike `file-writable-p'."
@@ -186,6 +192,27 @@ url-cache-create-filename
             (if (url-p url) url
               (url-generic-parse-url url)))))
 
+(defun url-cache-create-url-from-file (file)
+  (if (file-exists-p file)
+      (let* ((url-path-list
+	     (split-string
+	      (string-trim-right
+	       (string-trim-left
+		file
+		(concat "^.*/" (user-real-login-name)))
+	       "/[^/]+$") "/" t))
+	     (url-access-method
+	      (pop url-path-list))
+	     (url-domain-name
+	      (string-join
+	       (reverse url-path-list)
+	       "."))
+	     (url
+	      (string-join
+	       (list url-access-method url-domain-name)
+	       "://")))
+	url)))
+
 ;;;###autoload
 (defun url-cache-extract (fnam)
   "Extract FNAM from the local disk cache."
@@ -226,7 +253,22 @@ url-cache-prune-cache
 	   ((time-less-p
 	     (time-add
 	      (file-attribute-modification-time (file-attributes file))
-	      url-cache-expire-time)
+	      (or
+		(let ((expire-time
+		       (remove
+			nil
+			(mapcar
+			 (lambda (alist)
+			   (let ((key (car alist))
+				(value (cdr alist)))
+			     (if
+				 (string-match
+				  key
+				  (url-cache-create-url-from-file file))
+				  value)))
+			url-cache-expiry-alist))))
+		 (if (consp expire-time) (apply 'min expire-time) nil))
+	       url-cache-expire-time))
 	     now)
 	    (delete-file file)
 	    (setq deleted-files (1+ deleted-files))))))

[Message part 3 (text/plain, inline)]
I also didn't really like the way the code ended up being formatted. Is
there some guidance around splitting functions and their arguments
across multiple lines?

For the Gravatar change, I had this in mind.
[Message part 4 (text/x-patch, inline)]
diff --git a/lisp/image/gravatar.el b/lisp/image/gravatar.el
index f6f056a2ba..6fea19d942 100644
--- a/lisp/image/gravatar.el
+++ b/lisp/image/gravatar.el
@@ -41,15 +41,14 @@ gravatar-automatic-caching
   :group 'gravatar)
 (make-obsolete-variable 'gravatar-automatic-caching nil "28.1")
 
-(defcustom gravatar-cache-ttl 2592000
+(defcustom gravatar-cache-ttl 43200
   "Time to live in seconds for gravatar cache entries.
 If a requested gravatar has been cached for longer than this, it
-is retrieved anew.  The default value is 30 days."
+is retrieved anew.  The default value is 12 hours."
   :type 'integer
   ;; Restricted :type to number of seconds.
   :version "27.1"
   :group 'gravatar)
-(make-obsolete-variable 'gravatar-cache-ttl nil "28.1")
 
 (defcustom gravatar-rating "g"
   "Most explicit Gravatar rating level to allow.
@@ -287,8 +286,7 @@ gravatar-retrieve
 (defun gravatar--prune-cache ()
   (let ((expired nil)
         (time (- (time-convert (current-time) 'integer)
-                 ;; Twelve hours.
-                 (* 12 60 60))))
+                 gravatar-cache-ttl)))
     (maphash (lambda (key val)
                (when (< (car val) time)
                  (push key expired)))
[Message part 5 (text/plain, inline)]
Thanks!

-- 
Alex.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Tue, 15 Jun 2021 14:12:01 GMT) Full text and rfc822 format available.

Message #8 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alex Bochannek <alex <at> bochannek.com>
Cc: 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Tue, 15 Jun 2021 16:11:23 +0200
Alex Bochannek <alex <at> bochannek.com> writes:

> +(defcustom url-cache-expiry-alist nil
> +  "Alist of URL regular expressions to override the `url-cache-expire-time'."
> +  :version "28.1"
> +  :type 'alist
> +  :group 'url-cache)

Sure, adding this makes sense to me.

> +(defun url-cache-create-url-from-file (file)

I thought this existed, but I guess not...  

> +		(let ((expire-time
> +		       (remove
> +			nil
> +			(mapcar
> +			 (lambda (alist)
> +			   (let ((key (car alist))
> +				(value (cdr alist)))
> +			     (if
> +				 (string-match
> +				  key
> +				  (url-cache-create-url-from-file file))
> +				  value)))
> +			url-cache-expiry-alist))))
> +		 (if (consp expire-time) (apply 'min expire-time) nil))
> +	       url-cache-expire-time))
>  	     now)
>  	    (delete-file file)
>  	    (setq deleted-files (1+ deleted-files))))))
>
> I also didn't really like the way the code ended up being formatted. Is
> there some guidance around splitting functions and their arguments
> across multiple lines?

Well, we never do:

> +			     (if
> +				 (string-match

But in general, we just try to keep it readable, which means not going
too far in either horizontal nor vertical directions.  (So there's
really no rules for formatting beyond that.)  Your code in this patch
generally seems to be way too vertical.

> -                 ;; Twelve hours.
> -                 (* 12 60 60))))
> +                 gravatar-cache-ttl)))

I don't mind that -- but is this really something that somebody would
want to control?  It just seemed unlikely to me.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Tue, 15 Jun 2021 22:57:01 GMT) Full text and rfc822 format available.

Message #11 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Alex Bochannek <alex <at> bochannek.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Tue, 15 Jun 2021 15:55:54 -0700
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

>> -                 ;; Twelve hours.
>> -                 (* 12 60 60))))
>> +                 gravatar-cache-ttl)))
>
> I don't mind that -- but is this really something that somebody would
> want to control?  It just seemed unlikely to me.

I tend to find it difficult to reason about functionality if constants
like this are in the code and not in variables. It may be unlikely that
many people will want to customize it, but I'd rather expose this as a
configuration variable than hide a static value in the code.


As far as the URL caching code is concerned, I cleaned it up a bit and
added some simple tests and documentation.

Support URL-specific cache expiration

	* test/lisp/url/url-cache-tests.el: Test URL-to-filename and
	filename-to-URL mappings used by URL caching.

	* lisp/url/url-cache.el (url-cache-expiry-alist)
	(url-cache-create-url-from-file, url-cache-expired)
	(url-cache-prune-cache): Expire cache entries based on regular
	expressions matching URLs defined in new customizable variable
	url-cache-expire-alist.

	* doc/misc/url.texi (Disk Caching): Mention
	url-cache-expiry-alist variable.
[Message part 2 (text/x-patch, inline)]
diff --git a/doc/misc/url.texi b/doc/misc/url.texi
index 8f15e11007..2ea34e0d03 100644
--- a/doc/misc/url.texi
+++ b/doc/misc/url.texi
@@ -923,6 +923,12 @@ Disk Caching
 expire-time argument of the function @code{url-cache-expired}.
 @end defopt
 
+@defopt url-cache-expiry-alist
+This variable is an alist of regular expressions matching @var{url}'s
+and their associated expiration delay in seconds.  It is used by the
+functions @code{url-cache-expired} and @code{url-cache-prune-cache}.
+@end defopt
+
 @defun url-fetch-from-cache
 This function takes a URL as its argument and returns a buffer
 containing the data cached for that URL.
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index 830e6ba9dc..48f315a5cc 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -38,6 +38,15 @@ url-cache-expire-time
   :type 'integer
   :group 'url-cache)
 
+(defcustom url-cache-expiry-alist nil
+  "Alist of URL regular expressions to override the `url-cache-expire-time'.
+The key is a string to be matched against the URL of the cached entry and the
+value is the expire time in seconds.  Only the protocol and hostname of the URL
+are available for matching."
+  :version "28.1"
+  :type 'alist
+  :group 'url-cache)
+
 ;; Cache manager
 (defun url-cache-file-writable-p (file)
   "Follows the documentation of `file-writable-p', unlike `file-writable-p'."
@@ -186,6 +195,31 @@ url-cache-create-filename
             (if (url-p url) url
               (url-generic-parse-url url)))))
 
+(defun url-cache-create-url-from-file (file)
+  (let* ((url-path-list
+	  (split-string
+	   (file-name-directory
+	    (string-trim-left file (concat "^.*/" (user-real-login-name))))
+	    "/" t))
+	 (protocol (pop url-path-list))
+	 (hostname
+	  (string-join (reverse url-path-list) "."))
+	 (url (string-join (list protocol hostname) "://")))
+    url))
+
+(defun url-cache-expiry-by-url (url)
+  (let ((expire-time
+	 (remove nil
+		 (mapcar
+		  (lambda (alist)
+		    (let ((key (car alist))
+			  (value (cdr alist)))
+		      (if (string-match
+			   key url)
+			  value)))
+		  url-cache-expiry-alist))))
+    (if (consp expire-time) (apply 'min expire-time) nil)))
+
 ;;;###autoload
 (defun url-cache-extract (fnam)
   "Extract FNAM from the local disk cache."
@@ -204,7 +238,9 @@ url-cache-expired
 	  (time-less-p
 	   (time-add
 	    cache-time
-	    (or expire-time url-cache-expire-time))
+	    (or expire-time
+		(url-cache-expiry-by-url url)
+		url-cache-expire-time))
 	   nil)))))
 
 (defun url-cache-prune-cache (&optional directory)
@@ -226,8 +262,10 @@ url-cache-prune-cache
 	   ((time-less-p
 	     (time-add
 	      (file-attribute-modification-time (file-attributes file))
-	      url-cache-expire-time)
-	     now)
+	      (or (url-cache-expiry-by-url
+		   (url-cache-create-url-from-file file))
+		  url-cache-expire-time))
+	      now)
 	    (delete-file file)
 	    (setq deleted-files (1+ deleted-files))))))
       (if (< deleted-files total-files)
diff --git a/test/lisp/url/url-cache-tests.el b/test/lisp/url/url-cache-tests.el
new file mode 100644
index 0000000000..f4e49ce3b9
--- /dev/null
+++ b/test/lisp/url/url-cache-tests.el
@@ -0,0 +1,76 @@
+;;; url-cache-tests.el --- Test suite for url-cache.  -*- lexical-binding:t -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Alex Bochannek <alex <at> bochannek.com>
+;; Keywords: data
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'url-cache)
+
+(ert-deftest url-cache-url-to-filename-tests ()
+  "Test the URL to filename resolution for the URL cache"
+  (should (equal (file-name-directory
+		  (url-cache-create-filename "http://www.fsf.co.uk"))
+		 (string-join
+		  (list url-cache-directory (user-real-login-name)
+			"http/uk/co/fsf/www/") "/")))
+  (should (equal (file-name-directory
+		  (url-cache-create-filename "https://www.fsf.co.uk"))
+		 (string-join
+		  (list url-cache-directory (user-real-login-name)
+			"https/uk/co/fsf/www/") "/")))
+  (should (equal (file-name-directory
+		  (url-cache-create-filename "http://host"))
+		 (string-join
+		  (list url-cache-directory (user-real-login-name)
+			"http/host/") "/")))
+  (should (equal (file-name-directory
+		  (url-cache-create-filename "http://host:80"))
+		 (string-join
+		  (list url-cache-directory (user-real-login-name)
+			"http/host/") "/")))
+  (should (equal (file-name-directory
+		  (url-cache-create-filename "http://host#fragment"))
+		 (string-join
+		  (list url-cache-directory (user-real-login-name)
+			"http/host/") "/"))))
+
+(ert-deftest url-cache-filename-to-url-tests ()
+  "Test the filename to URL resolution for the URL cache"
+  (should (equal (url-cache-create-url-from-file
+		  (string-join
+		   (list url-cache-directory (user-real-login-name)
+			 "http/uk/co/fsf/www/") "/"))
+		 "http://www.fsf.co.uk"))
+  (should (equal (url-cache-create-url-from-file
+		  (string-join
+		   (list url-cache-directory (user-real-login-name)
+			 "https/uk/co/fsf/www/") "/"))
+		 "https://www.fsf.co.uk"))
+  (should (equal (url-cache-create-url-from-file
+		  (string-join
+		   (list url-cache-directory (user-real-login-name)
+			 "http/host/") "/"))
+		 "http://host")))
+
+(provide 'url-cache-tests)
+
+;;; url-cache-tests.el ends here
[Message part 3 (text/plain, inline)]
-- 
Alex.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Sat, 19 Jun 2021 12:15:01 GMT) Full text and rfc822 format available.

Message #14 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alex Bochannek <alex <at> bochannek.com>
Cc: 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Sat, 19 Jun 2021 14:14:47 +0200
Alex Bochannek <alex <at> bochannek.com> writes:

> I tend to find it difficult to reason about functionality if constants
> like this are in the code and not in variables. It may be unlikely that
> many people will want to customize it, but I'd rather expose this as a
> configuration variable than hide a static value in the code.

Adding user options to control things nobody has asked about isn't
helpful.

> Support URL-specific cache expiration
>
> 	* test/lisp/url/url-cache-tests.el: Test URL-to-filename and
> 	filename-to-URL mappings used by URL caching.
>
> 	* lisp/url/url-cache.el (url-cache-expiry-alist)
> 	(url-cache-create-url-from-file, url-cache-expired)
> 	(url-cache-prune-cache): Expire cache entries based on regular
> 	expressions matching URLs defined in new customizable variable
> 	url-cache-expire-alist.
>
> 	* doc/misc/url.texi (Disk Caching): Mention
> 	url-cache-expiry-alist variable.

Looks good to me.  What's the use case for this, though?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Sat, 19 Jun 2021 12:57:01 GMT) Full text and rfc822 format available.

Message #17 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Benjamin Riefenstahl <b.riefenstahl <at> turtle-trading.net>
To: Alex Bochannek <alex <at> bochannek.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Sat, 19 Jun 2021 14:56:40 +0200
Hi Alex,

>>> -                 ;; Twelve hours.
>>> -                 (* 12 60 60))))
>>> +                 gravatar-cache-ttl)))

> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>> I don't mind that -- but is this really something that somebody would
>> want to control?  It just seemed unlikely to me.

Alex Bochannek writes:
> I tend to find it difficult to reason about functionality if constants
> like this are in the code and not in variables.

Maybe use defconst instead?

Just a drive-by thought,
benny




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Sat, 19 Jun 2021 19:25:02 GMT) Full text and rfc822 format available.

Message #20 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Alex Bochannek <alex <at> bochannek.com>
To: Benjamin Riefenstahl <b.riefenstahl <at> turtle-trading.net>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Sat, 19 Jun 2021 12:24:00 -0700
[Message part 1 (text/plain, inline)]
Benjamin Riefenstahl <b.riefenstahl <at> turtle-trading.net> writes:

> Hi Alex,
>
>>>> -                 ;; Twelve hours.
>>>> -                 (* 12 60 60))))
>>>> +                 gravatar-cache-ttl)))
>
>> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>>> I don't mind that -- but is this really something that somebody would
>>> want to control?  It just seemed unlikely to me.
>
> Alex Bochannek writes:
>> I tend to find it difficult to reason about functionality if constants
>> like this are in the code and not in variables.
>
> Maybe use defconst instead?
>
> Just a drive-by thought,
> benny

I like that idea, that seems like a good compromise.

Thanks!
[Message part 2 (text/x-patch, inline)]
diff --git a/lisp/image/gravatar.el b/lisp/image/gravatar.el
index f6f056a2ba..ebae356e26 100644
--- a/lisp/image/gravatar.el
+++ b/lisp/image/gravatar.el
@@ -51,6 +51,9 @@ gravatar-cache-ttl
   :group 'gravatar)
 (make-obsolete-variable 'gravatar-cache-ttl nil "28.1")

+(defconst gravatar-cache-expiry (* 12 60 60)
+  "Time to live for gravatar cache entries (12 hours.)")
+
 (defcustom gravatar-rating "g"
   "Most explicit Gravatar rating level to allow.
 Some gravatars are rated according to how suitable they are for
@@ -287,8 +290,7 @@ gravatar-retrieve
 (defun gravatar--prune-cache ()
   (let ((expired nil)
         (time (- (time-convert (current-time) 'integer)
-                 ;; Twelve hours.
-                 (* 12 60 60))))
+                 gravatar-cache-expiry)))
     (maphash (lambda (key val)
                (when (< (car val) time)
                  (push key expired)))
[Message part 3 (text/plain, inline)]
-- 
Alex.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Sat, 19 Jun 2021 19:33:02 GMT) Full text and rfc822 format available.

Message #23 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Alex Bochannek <alex <at> bochannek.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Sat, 19 Jun 2021 12:32:13 -0700
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Alex Bochannek <alex <at> bochannek.com> writes:
>
>> Support URL-specific cache expiration
>>
>> 	* test/lisp/url/url-cache-tests.el: Test URL-to-filename and
>> 	filename-to-URL mappings used by URL caching.
>>
>> 	* lisp/url/url-cache.el (url-cache-expiry-alist)
>> 	(url-cache-create-url-from-file, url-cache-expired)
>> 	(url-cache-prune-cache): Expire cache entries based on regular
>> 	expressions matching URLs defined in new customizable variable
>> 	url-cache-expire-alist.
>>
>> 	* doc/misc/url.texi (Disk Caching): Mention
>> 	url-cache-expiry-alist variable.
>
> Looks good to me.  What's the use case for this, though?

I originally had looked at this for Gravatar entries and I am now using
it to avoid fetching the same images in RSS feeds. I just noticed though
that `url-cache-create-url-from-file' won't work if
`url-cache-create-filename-human-readable' is used. Any suggestions for
how to address that?

-- 
Alex.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Mon, 21 Jun 2021 12:22:02 GMT) Full text and rfc822 format available.

Message #26 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alex Bochannek <alex <at> bochannek.com>
Cc: 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Mon, 21 Jun 2021 14:21:43 +0200
Alex Bochannek <alex <at> bochannek.com> writes:

> I originally had looked at this for Gravatar entries and I am now using
> it to avoid fetching the same images in RSS feeds.

Right; makes sense.

> I just noticed though that `url-cache-create-url-from-file' won't work
> if `url-cache-create-filename-human-readable' is used. Any suggestions
> for how to address that?

No, sorry -- I'm pretty unfamiliar with the url-cache code.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Mon, 21 Jun 2021 18:26:01 GMT) Full text and rfc822 format available.

Message #29 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Alex Bochannek <alex <at> bochannek.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Mon, 21 Jun 2021 11:25:09 -0700
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Alex Bochannek <alex <at> bochannek.com> writes:
>
>> I originally had looked at this for Gravatar entries and I am now using
>> it to avoid fetching the same images in RSS feeds.
>
> Right; makes sense.
>
>> I just noticed though that `url-cache-create-url-from-file' won't work
>> if `url-cache-create-filename-human-readable' is used. Any suggestions
>> for how to address that?
>
> No, sorry -- I'm pretty unfamiliar with the url-cache code.

I need to think about this some more. The easy way is to not try to
recreate the URL but to have users specify the path for cache entries. I
might just do that and see how that works out for me in practice. Either
way, it's not ready for merging yet.

Thanks!

-- 
Alex.




Removed tag(s) patch. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 01 Aug 2021 11:17:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Sun, 24 Oct 2021 07:28:03 GMT) Full text and rfc822 format available.

Message #34 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Alex Bochannek <alex <at> bochannek.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Sun, 24 Oct 2021 00:27:16 -0700
Alex Bochannek <alex <at> bochannek.com> writes:

> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
>> Alex Bochannek <alex <at> bochannek.com> writes:
>>
>>> I originally had looked at this for Gravatar entries and I am now using
>>> it to avoid fetching the same images in RSS feeds.
>>
>> Right; makes sense.
>>
>>> I just noticed though that `url-cache-create-url-from-file' won't work
>>> if `url-cache-create-filename-human-readable' is used. Any suggestions
>>> for how to address that?
>>
>> No, sorry -- I'm pretty unfamiliar with the url-cache code.
>
> I need to think about this some more. The easy way is to not try to
> recreate the URL but to have users specify the path for cache entries. I
> might just do that and see how that works out for me in practice. Either
> way, it's not ready for merging yet.

(That was 17 weeks ago.)

Did you get any further here?  Thanks in advance.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Wed, 27 Oct 2021 16:37:01 GMT) Full text and rfc822 format available.

Message #37 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Alex Bochannek <alex <at> bochannek.com>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Wed, 27 Oct 2021 09:36:44 -0700
Stefan,

Stefan Kangas <stefan <at> marxist.se> writes:

> Alex Bochannek <alex <at> bochannek.com> writes:
>
>> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>>
>>> Alex Bochannek <alex <at> bochannek.com> writes:
>>>
>>>> I originally had looked at this for Gravatar entries and I am now using
>>>> it to avoid fetching the same images in RSS feeds.
>>>
>>> Right; makes sense.
>>>
>>>> I just noticed though that `url-cache-create-url-from-file' won't work
>>>> if `url-cache-create-filename-human-readable' is used. Any suggestions
>>>> for how to address that?
>>>
>>> No, sorry -- I'm pretty unfamiliar with the url-cache code.
>>
>> I need to think about this some more. The easy way is to not try to
>> recreate the URL but to have users specify the path for cache entries. I
>> might just do that and see how that works out for me in practice. Either
>> way, it's not ready for merging yet.
>
> (That was 17 weeks ago.)
>
> Did you get any further here?  Thanks in advance.

I did not have a chance to work on this any further. The problem here is
that the way URLs are mapped to a directory structure does not allow for
a reliable backwards mapping. A thought I had about this was to keep an
intermediate mapping for URLs to cache files around in the cache
itself. Might be interesting to see how browsers solve this in general
as not to reinvent the wheel.

If this is something you would want to work on, please feel free to do
so! I don't think I will have uninterrupted time to focus on this until
the end of the year.

-- 
Alex.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49033; Package emacs. (Wed, 27 Oct 2021 16:51:02 GMT) Full text and rfc822 format available.

Message #40 received at 49033 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Alex Bochannek <alex <at> bochannek.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 49033 <at> debbugs.gnu.org
Subject: Re: bug#49033: 28.0.50; [PATCH] Feature suggestion,
 url-cache-expiry-alist to override expire time for cache pruning
Date: Wed, 27 Oct 2021 09:50:19 -0700
Alex Bochannek <alex <at> bochannek.com> writes:

> If this is something you would want to work on, please feel free to do
> so! I don't think I will have uninterrupted time to focus on this until
> the end of the year.

No problem, there is no rush with this.  I was only checking in.

I currently have too many other projects to be able to take this on.  So
I guess the best chance for anything to happen here is for you to get to
it when you find the time.  If you do, it will be much appreciated.

Thanks!




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 12 Feb 2025 03:28:03 GMT) Full text and rfc822 format available.

This bug report was last modified 220 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.