| 94 | } |
| 95 | |
| 96 | func (s *Server) handleSVGInBackground(r *http.Request, b *rod.Browser) { |
| 97 | log.Println("New SVG request in background.") |
| 98 | |
| 99 | page := b.MustPage(fmt.Sprintf("http://localhost:8687/?%s", r.URL.Query().Encode())) |
| 100 | defer page.Close() |
| 101 | page.MustWaitLoad() |
| 102 | |
| 103 | if page.MustHas("#svg-container") { |
| 104 | svg := page.MustElement("#svg-container") |
| 105 | svgContent := svg.MustHTML() |
| 106 | |
| 107 | s.c.Set("cachedSvgContent:"+r.URL.Query().Encode(), svgContent, cache.DefaultExpiration) |
| 108 | s.c.Set("cachedSvgContent:old:"+r.URL.Query().Encode(), svgContent, 15778463000000000) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | func (s *Server) handleSVG(w http.ResponseWriter, r *http.Request, b *rod.Browser) { |
| 113 | if svgContent, found := s.c.Get("cachedSvgContent:" + r.URL.Query().Encode()); found { |