0

I have a web application where some images are generated by PHP.

For those that are familiar, these are badges that you can put on your GitHub's projects (in the README for example).

What headers do I need to set with PHP, when generating those images (.svg), so that CloudFlare caches them for a day?

FYI I am using the free plan.

CloudFlare's documentation is very lacking IMO, I can't find anything related to static resources and TTL. To be clear: I'm not caching HTML, I'm caching static resources (that are generated by PHP).

Matthieu Napoli
  • 48,448
  • 45
  • 173
  • 261

2 Answers2

0

Cloudflare respects what you put in HTTP headers. You just need to set a cache-Control: max-age value when returning your images. See this SO question.

Community
  • 1
  • 1
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
0

We automatically cache .svg by file extension.

What CloudFlare caches by default

The TTL is in your performance settings for the domain.

You do need to make sure you're not returning something like no-cache for us to cache it.

damoncloudflare
  • 2,079
  • 13
  • 9
  • In the performance settings, I can only set `Specify how long CloudFlare-cached resources will remain on your visitors' computers`. This doesn't specify how long CloudFlare will cache it: if visitors are different each time, browser caching is useless for my server. – Matthieu Napoli Sep 18 '14 at 21:49