Skip to content

Commit

Permalink
Disable caching for maps with custom params
Browse files Browse the repository at this point in the history
  • Loading branch information
bemyak committed Nov 15, 2022
1 parent 2f0f188 commit e693c24
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions atlas/atlas.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func (a *Atlas) SeedMapTile(ctx context.Context, m Map, z, x, y uint) error {
return defaultAtlas.SeedMapTile(ctx, m, z, x, y)
}

if len(m.Params) > 0 {
return nil
}

ctx = context.WithValue(ctx, observability.ObserveVarMapName, m.Name)
// confirm we have a cache backend
if a.cacher == nil {
Expand Down
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,19 @@ func (c *Config) Validate() error {
// check for map layer name / zoom collisions
// map of layers to providers
mapLayers := map[string]map[string]provider.MapLayer{}
// maps with configured parameters for logging
mapsWithCustomParams := []string{}
for mapKey, m := range c.Maps {

// validate any declared query parameters
if err := ValidateAndRegisterParams(string(m.Name), m.Parameters); err != nil {
return err
}

if len(m.Parameters) > 0 {
mapsWithCustomParams = append(mapsWithCustomParams, string(m.Name))
}

if _, ok := mapLayers[string(m.Name)]; !ok {
mapLayers[string(m.Name)] = map[string]provider.MapLayer{}
}
Expand Down Expand Up @@ -300,6 +306,13 @@ func (c *Config) Validate() error {
}
}

if len(mapsWithCustomParams) > 0 {
log.Infof(
"Caching is disabled for these maps, since they have configured custom parameters: %s",
strings.Join(mapsWithCustomParams, ", "),
)
}

// check for blacklisted headers
for k := range c.Webserver.Headers {
for _, v := range blacklistHeaders {
Expand Down

0 comments on commit e693c24

Please sign in to comment.