Caching policies added.

We used httpcache library to implement this. As it was not possible to support different policies, I mostly copied and modified it.
This commit is contained in:
Musab Gültekin
2019-07-07 12:18:40 +03:00
parent 0d6c2a6864
commit 90d2be2210
13 changed files with 2349 additions and 16 deletions

View File

@ -1,7 +1,7 @@
package geziyor
import (
"github.com/fpfeng/httpcache"
"github.com/geziyor/geziyor/cache"
"github.com/geziyor/geziyor/client"
"github.com/geziyor/geziyor/export"
"github.com/geziyor/geziyor/metrics"
@ -15,18 +15,25 @@ type Options struct {
// If empty, any domain is allowed
AllowedDomains []string
// Set this to enable caching responses.
// Memory Cache: httpcache.NewMemoryCache()
// Disk Cache: diskcache.New(".cache")
Cache httpcache.Cache
// Cache storage backends.
// - Memory
// - Disk
// - LevelDB
Cache cache.Cache
// Charset Detection disable
// Policies for caching.
// - Dummy policy (default)
// - RFC2616 policy
CachePolicy cache.Policy
// Response charset detection for decoding to UTF-8
CharsetDetectDisabled bool
// Concurrent requests limit
ConcurrentRequests int
// Concurrent requests per domain limit
// Concurrent requests per domain limit. Uses request.URL.Host
// Subdomains are different than top domain
ConcurrentRequestsPerDomain int
// If set true, cookies won't send.