Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 515391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:37:24+00:00 2026-05-13T07:37:24+00:00

I have finalized a small PHP application that can serve many documents. These documents

  • 0

I have finalized a small PHP application that can serve many documents. These documents must be cacheable by clients and proxies.

Since proxies can cache my results I must be extra careful because the documents I serve can have different MIMEs types (content negotiation based on $_SERVER[‘HTTP_ACCEPT’]) and different languages (based in this order: $_POST value / $_GET value / URL / PHP session value / $_COOKIE value / $_SERVER[‘HTTP_ACCEPT_LANGUAGE’] / default script value).

To shortly sum up, a page can be served with many MIME type and many languages with the same URL (question changed: see edit below).

To help cache on proxies I use the “Vary: Accept” header in combination with the ETag header. The ETags is a MD5 of the current language and the last modified timestamp.

I always:

  • Send an Expires header
  • Send a Cache-Control header
  • Send a Last-Modified header
  • Send a Content-Type header
  • Send an ETag header (based on current language and Last-Modified timestamp)
  • Send a Content-Language
  • Send a “Vary: Accept” header if the document is XHTML

Now with my question: is this enough to help cache on proxies and clients? Did I miss a thing/header?

To help you, here’s the HTTP response header for a test page (on my local environment):

"
Date             Wed, 30 Dec 2009 18:56:26 GMT
Server           Apache/2.0.63 (Win32) PHP/5.1.0
X-Powered-By     PHP/5.1.0
Set-Cookie       Tests=697daqbmple2e1daq2dg74ur96; path=/
Expires          Wed, 30 Dec 2009 21:56:26 GMT
Cache-Control    public, max-age=10800
Last-Modified    Mon, 28 Dec 2009 15:11:49 GMT
Etag             "44fa50be4638161a596e4b75d6ab7a94"
Vary             Accept
Content-Language en-us
Content-Length   3043
Keep-Alive       timeout=15, max=100
Connection       Keep-Alive
Content-Type     application/xhtml+xml; charset=UTF-8
"

EDIT: OK I understand that in this case serving a document with many MIMEs and having different languages (that can come from so many sources – see above) is just plain bad design. If you want to do this just use “private” cache (no cache on proxies)… Am I correct?

If each language have it’s own URL (but each URL can be served with many MIME still) is my current implementation is OK for a “public” cache (cache on clients + proxies)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:37:24+00:00Added an answer on May 13, 2026 at 7:37 am

    Since your output also depends on things a proxy cannot know like session data, won’t it be easier to send a (non-cachable) redirect to the actual content, which would be fixed for a given URL (with parameters) and therefore much easier to cache. I know this involves an extra round-trip, but it’s probably much less error-prone and would also cause less problems with proxies that don’t completely understand/support all your header combinations.

    Also, I’m guessing that, if you have two clients going through the same proxy but with different language cookies, your current method would return two different ETags for the same URL, which would make the proxy update its copy each time it sees the other client.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 483k
  • Answers 483k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Call CreateThread() to create a new thread. If you want… May 16, 2026 at 7:13 am
  • Editorial Team
    Editorial Team added an answer Try see what you get from this - some exercising… May 16, 2026 at 7:13 am
  • Editorial Team
    Editorial Team added an answer You need to add reference to the System.Transactions.dll assembly in… May 16, 2026 at 7:13 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.