git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v8 3/3] gitweb: add If-Modified-Since handling to git_snapshot().

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 30, 2012, 16:07 UTC
Message-ID
<201203301807.55284.jnareb@gmail.com>
In-Reply-To
<bfbde5354e25dfbf535307a72016a6b5ac3a2c56.1333024238.git.wking@drexel.edu>
On Thu, 29 Mar 2012, W. Trevor King wrote:
> Because snapshots can be large, you can save some bandwidth by
> supporting caching via If-Modified-Since.  This patch adds support for
> the i-m-s request to git_snapshot() if the request is a commit.
>

Perhaps it is worth clarifying that "caching" here means external HTTP caching, either by web browser, or by web accelerator / reverse proxy. Supporting Last-Modified and If-Modified-Since helps that[1][2].

[1]: http://www.mnot.net/cache_docs/#VALIDATE [2]: http://www.mnot.net/cache_docs/#SCRIPT

> Requests for snapshots of trees, which lack well defined timestamps,
> are still handled as they were before.

"still handled as they were before" means "do not support l-m / i-m-s", isn't it? Wouldn't it be better to write it explicitely?

> 
> Signed-off-by: W Trevor King <wking@drexel.edu>
Anyway, I like those changes:
  Acked-by: Jakub Narebski <jnareb@gmail.com>
[...]
Show 7 quoted lines
> +test_expect_success 'modification: tree snapshot' '
> +	ID=`git rev-parse --verify HEAD^{tree}` &&
> +	export HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" &&
> +	test_when_finished "unset HTTP_IF_MODIFIED_SINCE" &&
> +	gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
> +	grep "Status: 200 OK" gitweb.headers &&
> +	! grep -i "last-modified" gitweb.headers
If we ignore case, we can write
  +	! grep -i "Last-Modified:" gitweb.headers
which is IMVVVHO slightly more readable.
Not that it matters much.  Just nitpicking.
> +'
> +test_debug 'cat gitweb.headers'
-- 
Jakub Narebski
Poland
Previous: W. Trevor King
Message 18 of 18 in “gitweb: refactor If-Modified-Since handling”
  1. 0/3 gitweb: refactor If-Modified-Since handlingW. Trevor King, Mar 28, 2012
  2. 1/3 gitweb: add `status` headers to git_feed() responses.W. Trevor King, Mar 28, 2012
  3. 2/3 gitweb: refactor If-Modified-Since handlingW. Trevor King, Mar 28, 2012
  4. 3/3 gitweb: add If-Modified-Since handling to git_snapshot().W. Trevor King, Mar 28, 2012
  5. Jakub NarebskiMar 28, 2012
  6. W. Trevor KingMar 28, 2012
  7. Junio C HamanoMar 28, 2012
  8. W. Trevor KingMar 28, 2012
  9. Jakub NarebskiMar 28, 2012
  10. Jakub NarebskiMar 28, 2012
  11. 0/3 gitweb: refactor If-Modified-Since handlingW. Trevor King, Mar 29, 2012
  12. Junio C HamanoMar 30, 2012
  13. 1/3 gitweb: add `status` headers to git_feed() responses.W. Trevor King, Mar 29, 2012
  14. Jakub NarebskiMar 30, 2012
  15. 2/3 gitweb: refactor If-Modified-Since handlingW. Trevor King, Mar 29, 2012
  16. Jakub NarebskiMar 30, 2012
  17. 3/3 gitweb: add If-Modified-Since handling to git_snapshot().W. Trevor King, Mar 29, 2012
  18. Jakub NarebskiMar 30, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.