try varnish invalidation with all languages
This commit is contained in:
parent
1f24f03cf5
commit
85248787fc
@ -26,6 +26,14 @@ type nullHandler struct {
|
||||
access sync.Mutex
|
||||
}
|
||||
|
||||
func (self *nullHandler) ForEachI18N(v func(string)) {
|
||||
self.access.Lock()
|
||||
for lang := range self.i18n {
|
||||
v(lang)
|
||||
}
|
||||
self.access.Unlock()
|
||||
}
|
||||
|
||||
func (self *nullHandler) GetI18N(r *http.Request) *I18N {
|
||||
lang := r.URL.Query().Get("lang")
|
||||
if lang == "" {
|
||||
|
@ -17,7 +17,18 @@ type VarnishCache struct {
|
||||
}
|
||||
|
||||
func (self *VarnishCache) invalidate(r string) {
|
||||
var langs []string
|
||||
langs = append(langs, "")
|
||||
self.handler.ForEachI18N(func(lang string) {
|
||||
langs = append(langs, lang)
|
||||
})
|
||||
for _, lang := range langs {
|
||||
u, _ := url.Parse(r)
|
||||
if lang != "" {
|
||||
q := u.Query()
|
||||
q.Add("lang", lang)
|
||||
u.RawQuery = q.Encode()
|
||||
}
|
||||
resp, err := self.client.Do(&http.Request{
|
||||
Method: "PURGE",
|
||||
URL: u,
|
||||
@ -28,6 +39,7 @@ func (self *VarnishCache) invalidate(r string) {
|
||||
log.Println("varnish cache error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *VarnishCache) DeleteBoardMarkup(group string) {
|
||||
n, _ := self.handler.database.GetPagesPerBoard(group)
|
||||
|
Reference in New Issue
Block a user