Separate location for files served by php-fpm

Palvelin Postmaster postmaster at
Fri May 19 04:14:42 UTC 2023

> On 15. May 2023, at 17.15, Francis Daly <francis at> wrote:
> On Mon, May 15, 2023 at 12:46:14PM -1000, Palvelin Postmaster via nginx wrote:
>>> On 8. May 2023, at 8.49, Palvelin Postmaster via nginx <nginx at> wrote:
> Hi there,
>>> I use php-fpm together with nginx.
>>> My PHP app serves files which have hashed filenames and no filename extension from a specific subdirectory url, e.g /files/hash/31b4ba4a0dc6536201c25e92fe464f85
>>> I would like to be able to set, for example, a separate ’expires’ value to these files with nginx (using a separate location block?). Is that achiavable?
> In principle, yes. So long as the requests use different urls (excluding
> query string).
> In practice: from the words here, it is not entirely clear to me what
> your overall application is doing.
> Maybe you can have a location{} dedicated to these file-requests; or maybe
> it would be "cleaner" for the php side to add the extra Expires header.
> Can you show one or two sample requests that are made to nginx that you
> do want to have this extra Expires header; and one or two that you do
> not want to have this extra Expires header?
> The aim is to come up with a location{} block that matches only the
> requests that you want, if that is possible.


thanks for your response!

I wonder if you saw the server block that I had included in my original message? Doesn’t it answer your question regarding all the other requests?

My goal is to serve only requests which include URI /files/hash/* using a separate location block. Everything else should be served by the default location block I included in my previous message.

-- Hostmaster
postmaster at

More information about the nginx mailing list