Enable browser caching of static resources

This sends the Cache-Control header to allow caching of static resources,
and checks the If-Modified-Since header to allow browser to use the
cached resource on refresh. Also fixes some paths that caused redirects
(core//foo -> core/foo)
This commit is contained in:
Jakob Borg 2015-08-08 13:48:09 +02:00
parent dad1fb7805
commit 257d1afdf8
8 changed files with 19 additions and 13 deletions

View File

@ -955,6 +955,11 @@ func (s embeddedStatic) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
if r.Header.Get("If-Modified-Since") == auto.AssetsBuildDate {
w.WriteHeader(http.StatusNotModified)
return
}
mtype := s.mimeTypeForFile(file)
if len(mtype) != 0 {
w.Header().Set("Content-Type", mtype)
@ -970,6 +975,7 @@ func (s embeddedStatic) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(bs)))
w.Header().Set("Last-Modified", auto.AssetsBuildDate)
w.Header().Set("Cache-Control", "public")
w.Write(bs)
}

View File

@ -2,6 +2,6 @@ angular.module('syncthing.core')
.directive('httpErrorDialog', function () {
return {
restrict: 'A',
templateUrl: 'syncthing/core//httpErrorDialogView.html'
templateUrl: 'syncthing/core/httpErrorDialogView.html'
};
});

View File

@ -2,6 +2,6 @@ angular.module('syncthing.core')
.directive('majorUpgradeModal', function () {
return {
restrict: 'A',
templateUrl: 'syncthing/core//majorUpgradeModalView.html'
templateUrl: 'syncthing/core/majorUpgradeModalView.html'
};
});

View File

@ -2,6 +2,6 @@ angular.module('syncthing.core')
.directive('networkErrorDialog', function () {
return {
restrict: 'A',
templateUrl: 'syncthing/core//networkErrorDialogView.html'
templateUrl: 'syncthing/core/networkErrorDialogView.html'
};
});

View File

@ -2,6 +2,6 @@ angular.module('syncthing.core')
.directive('restartingDialog', function () {
return {
restrict: 'A',
templateUrl: 'syncthing/core//restartingDialogView.html'
templateUrl: 'syncthing/core/restartingDialogView.html'
};
});

View File

@ -2,6 +2,6 @@ angular.module('syncthing.core')
.directive('shutdownDialog', function () {
return {
restrict: 'A',
templateUrl: 'syncthing/core//shutdownDialogView.html'
templateUrl: 'syncthing/core/shutdownDialogView.html'
};
});

View File

@ -2,6 +2,6 @@ angular.module('syncthing.core')
.directive('upgradingDialog', function () {
return {
restrict: 'A',
templateUrl: 'syncthing/core//upgradingDialogView.html'
templateUrl: 'syncthing/core/upgradingDialogView.html'
};
});

File diff suppressed because one or more lines are too long