Skip to content
/ cachen Public

Golang library that simplify the way you manage the http cache.

License

Notifications You must be signed in to change notification settings

nerac/cachen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cachen

Build Status Coverage Status Go Report Card GoDoc

Golang library that simplify the way you manage the http cache.

Usage

Install the library with:

$ go get github.com/nerac/cachen

Import library into your code with as in the next example:

package main

import (
    "fmt"
    "net/http"
    "github.com/nerac/cachen"
)
func homeHandler(w http.ResponseWriter, r *http.Request) {
    cache := cachen.New()

    etag := "my etag"

    cache.ReusableRequest(true).
    RevalidateEachTime(false).
    IntermediatesAllowed(true).
    MaxAge(5 * SECONDS).
    StaleAllowed(true).
    Etag(etag).
    Bind(w,r)

    fmt.Fprintf(w, "This content is cached 5 seconds by all parties!")
}
func main() {

    http.HandleFunc("/", homeHandler)
    err := http.ListenAndServe(":8080", nil)
    if err != nil {
        log.Fatal("ListenAndServe: ", err)
    }
}

About

Golang library that simplify the way you manage the http cache.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages