Kartotherian should set expiry header on the tile responses to let Varnish know the policy
This task is connected to T186732
Kartotherian should set expiry header on the tile responses to let Varnish know the policy
This task is connected to T186732
| Subject | Author | Repo | Branch | Lines +/- | |
|---|---|---|---|---|---|
| maps: backport cache header configuration from upstream | Gehel | operations/puppet | production | +6 -0 |
| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| Invalid | None | T155601 Stabilizing Interactive Products | |||
| Resolved | Etonkovidova | T108435 Add proper expiry headers to kartotherian's responses |
According to Google's dev site:
Cache-Control header was defined as part of the HTTP/1.1 specification and supersedes previous headers (e.g. Expires) used to define response caching policies. All modern browsers support Cache-Control, hence that is all we will need.
I don't think we return Cache-Control header, so should we retarget this task to implement Cache-Control header?
I propose to start with just making every request Cache-Control:public, max-age=86400, s-maxage=86400 then we can bump the lifetime for tiles once we get purges right. API and static images can stay with 1 day lifetime.
We should also remove the ETag header or make it consistent between nodes as it is part of caching logic. And Last-Modified should not be epoch(0), we should drop it as well.
I chatted with @Gehel about this and, whilst we both agree that it is a must have for T155601: Stabilizing Interactive Products, we don't want to start working on it until we've resolved some of the other "must have" tasks to limit context switching due to having too much work in progress.
Are you sure you want the tiles public-cacheable as well? It takes load off of us, but it also puts the purging/invalidation of them on update out of our control (in the users' caches). We might want to sync up on how we want VCL to handle/mask the header as well (and all related things), maybe on IRC or Hangouts when we all get a chance.
What we are sure at this point:
I'd say that 1. and 2. are clearly wrong and need to be fixed. 3 is a low hanging fruit (and we already have the fix). 4 is a nice to have in case of trouble. So that's at least the priority order.
This is still broken and needs to be fixed, but we don't have a full team to work on it at this time; moving to backlog.
It looks like fixing this in the application will be non trivial. We don't even understand where those headers come from and grepping the code does not help (I personally don't understand much of how Node works, but I trust @MaxSem analysis on this). Which leaves 3 options:
My understanding from @BBlack is that we don't want to add application specific configuration in varnish, my understanding from @MaxSem is that this is something that is already done for multiple applications.
Both of these statements are true. We have a history of caving in to providing application-specific hacks (esp for MediaWiki), and we're trying to avoid that as much as possible going forward. The only thing that costs us more in the long run than doing the legwork to fix something properly in the application layer is hacking a fix into the Varnish layer instead. Promises to eventually move the Varnish fixups to the applayer are generally never delivered on, as it's hard to apply pressure to fix something that's already "working". The fixups accumulate into enormous debt and complexity over time at the cache layer, doing jobs that aren't properly the caches' to do.
Hi @GWicke - would you or your team be able to help us out with this? Thanks for any info! :)
Not doing this task will require us to manually flush and update Varnish for tiles that are out of sync. We haven't done this in a while, and only have had to do in a few instances, but it's painful, thus why this ticket was written.
Varnish is currently caching too much for too long, meaning that new tiles will take much longer to update for the end users. It's using an old epoch date (1970-?) for it's caching date (time since downloaded not time since last updated).
When we update all tiles with the new map style, we'll need to do a mass purge of all maps tiles in order to purge Varnish completely, which might cause some issues for at least 24 hours. This might cause some issues with some maps where both styles might be present in the same map for a short period of time (24 hours).
Moving to stalled/waiting until such time we have engineering resources to dig into the code and fix this.
Moving to prioritized - we need to do this, but don't have resources and I don't want it to drop off the board.
As discussed in sprint, the above commits fix some of the issues, but not all of them.
Hi everyone,
We are building a kartotherian instance, and noticed the issues with cache-related http headers.
I think this PR may help to understand why these are not consistent, and hopefully find a proper fix.
https://github.com/kartotherian/cassandra/pull/2
@Amatissart that's great! I don't know that part enough to review it myself, but at least that's a step in the right direction. Maybe @Yurik or @MaxSem could have a look...
Change 408832 had a related patch set uploaded (by Gehel; owner: Gehel):
[operations/puppet@production] maps: backport cache header configuration from upstream
Change 408832 merged by Gehel:
[operations/puppet@production] maps: backport cache header configuration from upstream
Cache-Control headers are now published. We could still improve the situation (in particular etags and last-modified are wrong), but this is tracked as T186732.
On the collab team "This Quarter" board (where, FYI, we put stuff we're actually working on), should this be in the "Needs Review" or "Code Review Started" or "QA Review" column? And I notice it's not assigned to anyone...
Yep, we can close it.
Side note: it is in the "Done" column on the Maps-Sprint board, which in the workflow we were using means: it is waiting for our product owner to confirm he is happy and knows the work has been done.
Check of the cache control header:
curl -v https://maps.wikimedia.org/osm-intl/6/40/18.png > /dev/null 2>| grep Cache-Control < Cache-Control: public, max-age=86400, s-maxage=86400
@Etonkovidova: you seemed to have an example of where cache control were not working as expected. Could you add that example?
@Gehel - It was on on betalabs which is not quite set up to deal with kartotherian afaik. On https://en.wikipedia.beta.wmflabs.org/wiki/Mavetuna from the Console ( though the Status code: 400 ):
Request URL: https://maps.wikimedia.org/img/osm-intl,9,37.7533,-122.4248,350x300.png?domain=en.wikipedia.beta.wmflabs.org&title=Mavetuna&groups=_7161fe6360995e63d3bd5da268d6cb9ca6eea240 cache-control:public, s-maxage=30, max-age=30
With curl:
curl -v https://maps.wikimedia.org/img/osm-intl,9,37.7533,-122.4248,350x300.png 2>&1 | grep Cache-Control < Cache-Control: max-age=3600
@Etonkovidova your test is actually hitting the production maps cluster. The Kartographer fronted is on betalabs, but it is depending on the production tiles / images. It looks this is using the snapshot service (which I don't know much about). So it looks like the snapshot service does not follow the same rules for headers. That's surprising, and probably a mistake, but I'm not familiar enough with the use case to know if there is a good reason to have a lower cache expiration on snapshots.
Thx, @Gehel! Closing this task as Resolved - if some additional work needs to be done later, another ticket can be created.