From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Sun, 26 Nov 2017 13:39:19 +0000 (+0000) Subject: http: Increase maxage for caching for images. (#4594). X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b46855b37bcc823c2d22a62d228df99b36e162ed;p=thirdparty%2Ftvheadend.git http: Increase maxage for caching for images. (#4594). Images were previously cached for 10 seconds. Since images rarely change and we now use icons for categories in the epg grid, it makes sense to cache them at the client for longer. Issue: #4594. --- diff --git a/src/webui/webui.c b/src/webui/webui.c index 622540593..2652e0f08 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -292,6 +292,7 @@ page_static_file(http_connection_t *hc, const char *_remain, void *opaque) char buf[4096]; const char *gzip = NULL; int nogzip = 0; + int maxage = 10; /* Default age */ if(_remain == NULL) return HTTP_STATUS_NOT_FOUND; @@ -316,10 +317,14 @@ page_static_file(http_connection_t *hc, const char *_remain, void *opaque) content = "text/css; charset=UTF-8"; else if(!strcmp(postfix, "git")) nogzip = 1; - else if(!strcmp(postfix, "jpg")) - nogzip = 1; - else if(!strcmp(postfix, "png")) + else if(!strcmp(postfix, "jpg") || !strcmp(postfix, "png")) { nogzip = 1; + /* Increase amount of time in seconds that a client can cache + * images since they rarely change. This avoids clients + * requesting category icons frequently. + */ + maxage = 60 * 60; + } } fb_file *fp = fb_open(path, 0, (nogzip || gzip) ? 0 : 1); @@ -332,7 +337,7 @@ page_static_file(http_connection_t *hc, const char *_remain, void *opaque) gzip = "gzip"; http_send_begin(hc); - http_send_header(hc, 200, content, size, gzip, NULL, 10, 0, NULL, NULL); + http_send_header(hc, 200, content, size, gzip, NULL, maxage, 0, NULL, NULL); while (!fb_eof(fp)) { ssize_t c = fb_read(fp, buf, sizeof(buf)); if (c < 0) {