nocache

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2021 License: MIT Imports: 2 Imported by: 1

README

NoCache

Build Status Go Report Card GoDoc

NoCache is a simple piece of middleware that sets a number of HTTP headers to prevent a router (or subrouter) from being cached by an upstream proxy and/or client.

Installation

go get github.com/alexander-melentyev/gin-nocache

Usage

package main

import (
     "github.com/gin-gonic/gin"
     nocache "github.com/alexander-melentyev/gin-nocache"
 )

func main() {
	g := gin.New()
	g.Use(nocache.NoCache())
	g.GET("/", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"result": "It will not be cached",
        })
    })
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoCache

func NoCache() gin.HandlerFunc

NoCache is a simple piece of middleware that sets a number of HTTP headers to prevent a router (or subrouter) from being cached by an upstream proxy and/or client.

As per http://wiki.nginx.org/HttpProxyModule - NoCache sets:

Expires: Thu, 01 Jan 1970 00:00:00 UTC
Cache-Control: no-cache, no-store, no-transform, must-revalidate, private, max-age=0
Pragma: no-cache (for HTTP/1.0 proxies/clients)
X-Accel-Expires: 0

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL