Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

purge-fastly 1011 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  1. #!/usr/bin/env bash
  2. # [start-readme]
  3. #
  4. # Run this script to manually purge the Fastly cache.
  5. # Note this script requires a `FASTLY_SERVICE_ID` and `FASTLY_TOKEN` in your `.env` file.
  6. #
  7. # [end-readme]
  8. usage()
  9. {
  10. echo "Error! Unable to purge the Fastly cache"
  11. echo ""
  12. echo "Add FASTLY_SERVICE_ID and FASTLY_TOKEN to the environment or create a .env file in the project root and set these values:"
  13. echo ""
  14. echo "FASTLY_SERVICE_ID=<value-goes-here>"
  15. echo "FASTLY_TOKEN=<value-goes-here>"
  16. exit
  17. }
  18. # attempt to load from .env if Fastly config is not already in ENV
  19. if [ -z "$FASTLY_SERVICE_ID" ] || [ -z "$FASTLY_TOKEN" ]; then
  20. # abort if .env file doesn't exist
  21. [ -f .env ] || usage
  22. # load config from .env
  23. export $(cat .env | xargs)
  24. fi
  25. if [ -z "$FASTLY_SERVICE_ID" ] || [ -z "$FASTLY_TOKEN" ]; then
  26. usage
  27. else
  28. curl -H "fastly-key: $FASTLY_TOKEN" -H "accept: application/json" -H "fastly-soft-purge: 1" -X POST "https://api.fastly.com/service/$FASTLY_SERVICE_ID/purge/all-the-things"
  29. fi
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...