Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/derom/amp-cache-purge

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/derom/amp-cache-purge

  • v0.0.0-20211221175844-e781b8049b3c
  • Source
  • Go
  • Socket score

Version published
Created
Source

Amp cache purging experiment - https://developers.google.com/amp/cache/update-cache

Supported Caches

Based on https://amp.dev/documentation/guides-and-tutorials/learn/amp-caches-and-cors/amp-cache-urls/

  • /c - Content: This is an AMP document served as a standalone page which may be linked to directly in some interfaces.
  • /v - Viewer: This is also an AMP document, but is served in an AMP Viewer which is a frame environment that displays an AMP document in the context of a Search Result Page or other interface.
  • /wp - Web Package: This is an AMP document served as a Signed Exchange, a Web Package technology. These URLs act as redirects to the publisher’s own origin.

Configuration

PRIVATE_KEY_LOCATION - default="private-key.pem". The private key from this repo is for tests.

PRIVATE_KEY_PASSWORD - default=""

Usage example

Here is an example http server. Purging requests are slow, so it's strongly recommended to use a queue(for example, rabbitmq) instead of direct http requests.

package main

import (
	"net/http"

	ampcachepurge "github.com/derom/amp-cache-purge"
)

func purgeHandler(w http.ResponseWriter, req *http.Request) {
	url := req.FormValue("url")

	httpClient := &http.Client{}
	err := ampcachepurge.PurgeUrl(url, httpClient)

	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	w.Write([]byte("success"))
}

func main() {
	http.HandleFunc("/purge", purgeHandler)

	http.ListenAndServe(":8090", nil)
}

FAQs

Package last updated on 21 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc