# Conservando unicórnios servindo imagens com nginx?

**URL:** <https://meta.discourse.org/t/conserving-unicorns-by-serving-images-with-nginx/177775>\
**Category:** Development\
**Created:** [Janeiro 30, 2021, 2:13pm UTC](https://meta.discourse.org/t/conserving-unicorns-by-serving-images-with-nginx/177775 "2021-01-30T14:13:17Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![mcdanlj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcdanlj/32/131829_2.png) [@mcdanlj](https://meta.discourse.org/u/mcdanlj)\
**Post date:** [Janeiro 30, 2021, 4:29pm UTC](https://meta.discourse.org/t/conserving-unicorns-by-serving-images-with-nginx/177775/5 "2021-01-30T16:29:37Z")

</div>

Eu apostaria que habilitar o cache no nginx externo traria o mesmo benefício em relação ao carregamento dos unicórnios, sem precisar configurar um CDN. Vejo cabeçalhos de controle de cache em todos os ativos de JavaScript, então talvez eu tente isso…

… bem, vejo que o nginx interno já está usando `proxy_cache` com validade de 7 dias para solicitações sem erro:

```plaintext
    location ~ ^/(svg-sprite/|letter_avatar/|letter_avatar_proxy/|user_avatar|highlight-js|stylesheets|theme-javascripts|favicon/proxied|service-worker) {
      ...
      # note x-accel-redirect can not be used with proxy_cache
      proxy_cache one;
      proxy_cache_key "$scheme,$host,$request_uri";
      proxy_cache_valid 200 301 302 7d;
      proxy_cache_valid any 1m;
      proxy_pass http://discourse;
      break;
    }

```

Como um CDN ajuda com os unicórnios nesse caso? Vejo `stylesheets` nessa lista.

---

_[View the full topic](https://meta.discourse.org/t/conserving-unicorns-by-serving-images-with-nginx/177775)._
