Skip to content

Commit

Permalink
changed static files expiration to 2h
Browse files Browse the repository at this point in the history
  • Loading branch information
MightyPork committed Sep 5, 2017
1 parent 3e21e83 commit 13fa224
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/httpd.c
Expand Up @@ -137,7 +137,7 @@ void httpdAddCacheHeaders(HttpdConnData *connData, const char *mime)
if (streq(mime, "text/csv")) return;
if (streq(mime, "application/json")) return;

httpdHeader(connData, "Cache-Control", "max-age=3600, public, must-revalidate");
httpdHeader(connData, "Cache-Control", "max-age=7200, public, must-revalidate");
}

const char *httpdGetVersion(void)
Expand Down

5 comments on commit 13fa224

@chmorgan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MightyPork, what was the reasoning behind this change?

@MightyPork
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's simple, I keep testing with some static assets and it kept needlessly reloading them every hour.

It could be made configurable, of course

@chmorgan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let me make that a Kconfig option, that imo would provide the most flexibility. Isn't there an issue with stale assets if the asset changes and the browser doesn't check again because the timeout is so long?

@MightyPork
Copy link
Owner Author

@MightyPork MightyPork commented on 13fa224 Sep 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for static assets, they don't normally change unless you re-flash the chip with new ones. But it's still a little inflexible w.r.t. custom assets / files users might want to add. Maybe there should be a weak external function that users can choose to do this instead of this built-in one

something like

 void httpdAddCacheHeaders(HttpdConnData *connData, const char *mime)
 {
    if (userAddCacheHeaders) {
        userAddCacheHeaders(connData, mime);
        return;
    }

 	if (streq(mime, "text/html")) return;
 	if (streq(mime, "text/plain")) return;
  	if (streq(mime, "text/csv")) return;
  	if (streq(mime, "application/json")) return;
  
 	httpdHeader(connData, "Cache-Control", "max-age=3600, public, must-revalidate");
 	httpdHeader(connData, "Cache-Control", "max-age=7200, public, must-revalidate");
  }

@chmorgan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could be an option.

I've been away working on hardware related things for a bit but should be back on software in the near future and back into the library as well to try to merge some of the remaining parts that I haven't gotten to so far. Pull requests still welcome! ;-)

Please sign in to comment.