Add a caching flag to page provider content.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9cafe20ff8
commit
3792ff2a4d
@ -65,9 +65,10 @@ func (ph *PageHandler) ServeHTTP(writer http.ResponseWriter, request *http.Reque
|
||||
|
||||
if pageContentType == "" {
|
||||
if provider := ph.PageProviders[actualPagePath]; provider != nil {
|
||||
pageContentType, pageContent = provider.GetContents(queryCollection)
|
||||
var canCache bool
|
||||
pageContentType, pageContent, canCache = provider.GetContents(queryCollection)
|
||||
lastMod = provider.GetLastModified()
|
||||
if pageContentType != "" && ph.CacheSettings.EnableContentsCaching {
|
||||
if pageContentType != "" && canCache && ph.CacheSettings.EnableContentsCaching {
|
||||
ph.setPageToCache(request.URL, actualQueries, &CachedPage{
|
||||
Content: pageContent,
|
||||
ContentType: pageContentType,
|
||||
|
@ -9,6 +9,6 @@ type PageProvider interface {
|
||||
GetPath() string
|
||||
GetSupportedURLParameters() []string
|
||||
GetLastModified() time.Time
|
||||
GetContents(urlParameters url.Values) (contentType string, contents []byte)
|
||||
GetContents(urlParameters url.Values) (contentType string, contents []byte, canCache bool)
|
||||
PurgeTemplate()
|
||||
}
|
||||
|
@ -26,13 +26,13 @@ func (tp *TestPage) GetLastModified() time.Time {
|
||||
return startTime
|
||||
}
|
||||
|
||||
func (tp *TestPage) GetContents(urlParameters url.Values) (contentType string, contents []byte) {
|
||||
func (tp *TestPage) GetContents(urlParameters url.Values) (contentType string, contents []byte, canCache bool) {
|
||||
if val, ok := urlParameters["test"]; ok {
|
||||
if len(val) > 0 {
|
||||
return "text/plain", ([]byte)("Testing!\r\n" + val[0])
|
||||
return "text/plain", ([]byte)("Testing!\r\n" + val[0]), len(val) == 1
|
||||
}
|
||||
}
|
||||
return "text/plain", ([]byte)("Testing!")
|
||||
return "text/plain", ([]byte)("Testing!"), true
|
||||
}
|
||||
|
||||
func (tp *TestPage) PurgeTemplate() {
|
||||
|
Loading…
Reference in New Issue
Block a user