|
@@ -44,6 +44,7 @@ type Short struct {
|
|
|
replication xweb.Mapper `xweb:"/front/shorturl/replication"` //用户复制操作记录入库
|
|
|
nologinArticle xweb.Mapper `xweb:"/nologin/(\\w+)/(.*).html"` //([pm]) 无需登录
|
|
|
whiteList xweb.Mapper `xweb:"/initialize/whiteList"` //白名单初始化
|
|
|
+ clearCache xweb.Mapper `xweb:"/front/free/clearCache"` //清楚缓存
|
|
|
}
|
|
|
|
|
|
var (
|
|
@@ -92,8 +93,17 @@ var (
|
|
|
"indexcontent": true, //老首页 seo入口 供爬虫使用
|
|
|
"advancedProject": false,
|
|
|
}
|
|
|
+ cacheIndex = []byte{}
|
|
|
)
|
|
|
|
|
|
+func (s *Short) ClearCache() {
|
|
|
+ log.Println("before cacheIndex:", string(cacheIndex))
|
|
|
+ if len(cacheIndex) > 0 {
|
|
|
+ cacheIndex = []byte{}
|
|
|
+ }
|
|
|
+ log.Println("after cacheIndex:", string(cacheIndex))
|
|
|
+}
|
|
|
+
|
|
|
func (s *Short) WhiteList() error {
|
|
|
ipInitAuthentication := s.GetString("ipInitAuthentication")
|
|
|
if ipInitAuthentication == config.Sysconfig["ipInitAuthentication"] {
|
|
@@ -171,7 +181,7 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
|
|
|
return s.Render("/pc/detail/biddetail_login.html", &s.T)
|
|
|
}
|
|
|
} else if userId != "" && strings.Contains(s.Request.RequestURI, "article") {
|
|
|
- mobileHtmlKey := "jy_mobile_index_wx"
|
|
|
+ //mobileHtmlKey := "jy_mobile_index_wx"
|
|
|
var loginPageInfo = func() (body []byte) {
|
|
|
// 获取页面内容
|
|
|
mobileUrl := fmt.Sprintf("%s%s", config.Sysconfig["webdomain"].(string), "/jy_mobile/index.html")
|
|
@@ -196,20 +206,19 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
|
|
|
log.Println(s.ResponseWriter, "Failed to read response body", http.StatusInternalServerError)
|
|
|
return
|
|
|
}
|
|
|
- err = redis.PutBytes(redisLimitation, mobileHtmlKey, &body, 3*24*60*60)
|
|
|
- if err != nil {
|
|
|
- log.Println("mobile html redis cache err :", err.Error())
|
|
|
- }
|
|
|
+ //err = redis.PutBytes(redisLimitation, mobileHtmlKey, &body, 3*24*60*60)
|
|
|
+ //if err != nil {
|
|
|
+ // log.Println("mobile html redis cache err :", err.Error())
|
|
|
+ //}
|
|
|
return
|
|
|
}
|
|
|
// 将页面内容返回给前端
|
|
|
s.ResponseWriter.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
|
- body, err := redis.GetBytes(redisLimitation, mobileHtmlKey)
|
|
|
- if err == nil && body != nil && len(*body) > 0 {
|
|
|
- s.ResponseWriter.Write(*body)
|
|
|
- return nil
|
|
|
+ //body, err := redis.GetBytes(redisLimitation, mobileHtmlKey)
|
|
|
+ if len(cacheIndex) == 0 {
|
|
|
+ cacheIndex = loginPageInfo()
|
|
|
}
|
|
|
- s.ResponseWriter.Write(loginPageInfo())
|
|
|
+ s.ResponseWriter.Write(cacheIndex)
|
|
|
return nil
|
|
|
}
|
|
|
//getsession := s.Session().GetMultiple()
|