Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

webserver: improved file caching #1366

Merged
merged 6 commits into from Sep 7, 2012

Conversation

Projects
None yet
2 participants
Owner

Montellese commented Sep 4, 2012

These commits contain some additional code to improve client-side caching of files exposed through xbmc's webserver. I have discussed these things with @da-anda at devcon. The changes are:

  • raise the value of the "Expires" header to 1 year in the future (currently it's 1 day)
  • provide the "Last-Modified" header for any "physical" file
  • check for "If-Modified-Since" request header and return HTTP 304 "Not Modified" instead of the whole file

All these changes should speed up retrieval of files through xbmc's webserver, especially for webinterfaces that show a lot of images.

@ghost ghost assigned Montellese Sep 4, 2012

@da-anda da-anda and 1 other commented on an outdated diff Sep 4, 2012

xbmc/network/WebServer.cpp
CDateTime expiryTime = CDateTime::GetCurrentDateTime();
- expiryTime += CDateTimeSpan(1, 0, 0, 0);
+ expiryTime += CDateTimeSpan(365, 0, 0, 0);
@da-anda

da-anda Sep 4, 2012

Member

could we add a condition to only set the expiration time to 1 year on files that are no HTML sites? I'd like to prevent that addon html files probably get cached that long by some browsers/clients - just to be really sure. So something like:

c_int expiryDuration = CDateTimeSpan(356, 0, 0, 0);

if (ext.c_str() == "htm" || ext.c_str() == "html") {
 expiryDuration = CDateTimeSpan(1, 0, 0, 0);
}

expiryTime += expiryDuration;

ofc only if this is the right place for it

@Montellese

Montellese Sep 4, 2012

Owner

So caching HTML pages for a day and non-HTML pages for a year? Shouldn't be a problem.

@da-anda

da-anda Sep 4, 2012

Member

Yes. HTML pages are the only thing a addon editor cannot link versioned (at least not the index.html) - so probably better don't let browsers cache them that long just to be really sure updated addons are loaded by the browsers.

@Montellese Montellese added a commit that referenced this pull request Sep 7, 2012

@Montellese Montellese Merge pull request #1366 from Montellese/webserver_caching
webserver: improved file caching
c55558e

@Montellese Montellese merged commit c55558e into xbmc:master Sep 7, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment