1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-09-16 09:36:18 +02:00

Cache buster

This commit is contained in:
DarthSim
2018-10-29 14:54:30 +06:00
parent d009dc6835
commit 8030e0aa27
2 changed files with 29 additions and 0 deletions

View File

@@ -198,6 +198,19 @@ Read more about presets in the [Presets](./presets.md) guide.
Default: empty
##### Cache buster
```
cachebuster:%string
cb:%string
```
Cache buster doesn't affect image processing but it's changing allows to bypass CDN, proxy server and browser cache. Useful when you have changed some things that are not reflected in the URL like image quality settings, presets or watermark data.
It's highly recommended to prefer `cachebuster` option over URL query string because the option can be properly signed.
Default: empty
##### Format
```

View File

@@ -118,6 +118,8 @@ type processingOptions struct {
Blur float32
Sharpen float32
CacheBuster string
Watermark watermarkOptions
UsedPresets []string
@@ -503,6 +505,16 @@ func applyFormatOption(po *processingOptions, args []string) error {
return nil
}
func applyCacheBusterOption(po *processingOptions, args []string) error {
if len(args) > 1 {
return fmt.Errorf("Invalid cache buster arguments: %v", args)
}
po.CacheBuster = args[0]
return nil
}
func applyProcessingOption(po *processingOptions, name string, args []string) error {
switch name {
case "format", "f", "ext":
@@ -557,6 +569,10 @@ func applyProcessingOption(po *processingOptions, name string, args []string) er
if err := applyPresetOption(po, args); err != nil {
return err
}
case "cachebuster", "cb":
if err := applyCacheBusterOption(po, args); err != nil {
return err
}
default:
return fmt.Errorf("Unknown processing option: %s", name)
}