# Best way to cache static files

**URL:** <https://www.ruby-forum.com/t/best-way-to-cache-static-files/197458>\
**Category:** NGINX\
**Created:** [October 14, 2010, 6:16pm UTC](https://www.ruby-forum.com/t/best-way-to-cache-static-files/197458 "2010-10-14T18:16:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [October 14, 2010, 6:16pm UTC](https://www.ruby-forum.com/t/best-way-to-cache-static-files/197458/1 "2010-10-14T18:16:15Z")

</div>

What is the preferred way to cache static files these days? (i.e.  
ccs/js)

1. Recompile with slowfs module
2. Serve css/js through php backend and use fastcgi\_cache
3. Create additional nginx localhost server and proxy\_cache from nginx  
backend

Drupal6 has a nasty habit of recreating its aggregated css and js files  
(i.e. css\_[md5hash].css) on module updates, etc. Which means cached  
dynamic pages end up pointing to non-existent files. An nginx cache  
could protect against that problem, but I’m not sure of the best way to  
do it.

Posted at Nginx Forum:

> **[Best way to cache static files](https://forum.nginx.org/read.php?2,140660,140660#msg-140660)**
>
> What is the preferred way to cache static files these days? (i.e. ccs/js) 1. Recompile with slowfs module 2. Serve css/js through php backend and use fastcgi\_cache 3. Create additional nginx localhost server and proxy\_cache from nginx backend Drupal6...

---

<div class="post-metadata">

**Author:** ![brianmercer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/839c29/32.png) [@brianmercer](https://www.ruby-forum.com/u/brianmercer)\
**Post date:** [October 14, 2010, 6:38pm UTC](https://www.ruby-forum.com/t/best-way-to-cache-static-files/197458/2 "2010-10-14T18:38:52Z")

</div>

Hi,

One idea…

With nginx proxy\_cache you can use “proxy\_cache\_use\_stale” to tell it to  
return the last known copy of a cached file on given backend errors.  
If you do that for 404 error for css\ __.css & js\__.js, it means that  
cached  
users will no longer be redirected to non existent css, instead they  
will be  
loading the css the page was using when it was cached.

Read more here:

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

Best regards from Montevideo,

Guzmn

On Thu, Oct 14, 2010 at 2:15 PM, brianmercer [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> What is the preferred way to cache static files these days? (i.e.  
> ccs/js)
> 
> 1. Recompile with slowfs module

1. Serve css/js through php backend and use fastcgi\_cache
