package cache import ( "fmt" "time" ) // CachedPage represents a cached HTML page type CachedPage struct { Content string ETag string LastUpdated time.Time Compressed []byte // Pre-compressed gzip content } // IsStale checks if the cached page is stale based on maxAge func (cp *CachedPage) IsStale(maxAge time.Duration) bool { return time.Since(cp.LastUpdated) > maxAge } // GenerateETag generates an ETag for the content func GenerateETag(content string) string { // Simple ETag based on content hash hash := 0 for _, b := range []byte(content) { hash = hash*31 + int(b) } return fmt.Sprintf(`"%x"`, hash) }