WebFaction
Community site: login faq

I have wordpress installed.

To make it a bit faster, I've created a few "static-only symbolic-link" apps so that Nginx is used to retrieve images/css/js instead of apache.

Now that I have this working, I've realized that no HTTP headers that enable browser caching of the images/css/js are being sent by Nginx. As a result, the files are being re-retrieved by website visitors on every page view.

How can I get Nginx to send an "expires" header, even if it's just 1 hour?

Thanks
Tim

asked 08 Mar '13, 23:55

turgs
7410
accept rate: 0%

edited 09 Mar '13, 00:05


Expires headers are not available from "Symbolic link to static-only app" applications. Instead, you should create a "Symbolic link to static/cgi/php54 app" application, and then use a .htaccess file containing the following directives:

# Use some aggressive client-side caching.
# Results in *significant* speed increases for page elements that are used
# repeatedly.  The elements are totally cached, and no requests are made, not
# even to check if the item has been modified.  This means that you need
# to use a new filename to push new content to clients -- you can't just edit
# the file on the server because the clients won't request the new version.
<IfModule mod_headers.c>
    Header unset ETag
    Header unset Last-Modified
    Header set Expires "Fri, 04 Nov 2021 21:59:49 GMT"
</IfModule>
permanent link

answered 09 Mar '13, 09:52

likebike
3366
accept rate: 28%

Thanks for your suggestion. The Wordpress site is already a "static/cgi/php54 app", so I think I can do this already without creating a sympolic link. The point is I want to use the power of Nginx to deliver the static files, but with browser caching too.

(09 Mar '13, 18:40) turgs

Another way to do this would be:

  • Create a new static-only application (not the symlink app), with "expires max" in the extra info field.
  • Move all of your static assets from their present locations to the static-only app directory.
  • Delete the original directories, and create symlinks (with the "ln -s" comman) pointing to your static-only app directory in their place.
permanent link

answered 09 Mar '13, 14:38

seanf
12.2k41836
accept rate: 37%

This is very interesting. I'll try this and let you know.

(09 Mar '13, 18:41) turgs
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×186
×125
×28
×17
×10

question asked: 08 Mar '13, 23:55

question was seen: 6,575 times

last updated: 09 Mar '13, 18:41

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM