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 6355831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:50:43+00:00 2026-05-24T22:50:43+00:00

I need to generate and deliver a relatively large JSON file to users. By

  • 0

I need to generate and deliver a relatively large JSON file to users. By large, I mean 400 KB. It’s the join of two tables, and it will probably get larger over time. I’m planning on using it to fill in the gaps in an HTML table, linking up items via IDs from the database.

To save bandwidth, I only wanted the client to download this JSON file once per day. (The easy options seem to be “every time” and “never”… grr.) In reality, it will update less often server-side, but I don’t want it less frequent. 90% of the browsers hitting this are IE7/8, if that makes a difference.

For server-side caching, I’m currently just dropping the JSON file into a text file on the server if it’s older than a few hours. I understand I could use memcached instead. Does memcached have a considerable advantage over a file? (Single server, 1k visitors per day, I don’t have memcached installed yet.)

Per the PHP manual comments, I tried this:

$expires = 60*60*24;
header("Pragma: public");
header("Cache-Control: maxage=".$expires);
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');

But it appears to do nothing. Chrome is informing me that it is “OK” each and every time I load the generating page directly, and no headers regarding cache control show up under the network/headers tab. I’m not explicitly hitting refresh. Doesn’t look like I’m caching at all. Are there any other ways to save the client some time and bandwidth? Best idea I have is creative tinkering with the .ajax() cache option.

I haven’t actually gotten as far as implementing the Ajax call yet. Baby steps.

(Sorry if I’m a bit wordy. Yell at me and I’ll improve the question as much as I can when it is needed. I’ve done some searching here and on Google and haven’t come across anything super useful yet. Maybe I don’t have the right key terms.)

Note: I’m running PHP under IIS 7, so it’s CGI. I feel like I read that might make a difference.

  • 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-24T22:50:45+00:00Added an answer on May 24, 2026 at 10:50 pm

    Sending the correct cache headers is only half the steps needed. You still need to send 304 status saying nothing has changed since the last time the client got the content. This can get tricky. I recommend using .htaccess to do this caching instead. More can be found here

    Example

    ExpiresActive On
    ExpiresDefault "access plus 1 day"
    

    Edit–

    If you had to do it all in php then you have to manually check the request headers and send 304.
    This how you can do it:

    $last_modified_time = filemtime($file); 
    $etag = md5_file($file); 
    header("Last-Modified: ".gmdate("D, d M Y H:i:s", $last_modified_time)." GMT"); 
    header("Etag: $etag"); 
    if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time || 
        trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) { 
        header("HTTP/1.1 304 Not Modified"); 
        exit; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to generate an XML file in C#. I want to write the
I need to generate the following: (clojureql.core/join (clojureql.core/table db :tableA) (clojureql.core/table db :tableA) (clojureql.core/where
I need to generate a pdf from a tex file, as a temporary file.
I need to generate java class definition from json data. Is there any tool
I need to generate a XSD for a XML file we are gonna use
I need to generate a flat file with several different sections, each with different
I need to generate a report file from my don net app. i need
If I need generate a fairly large dataset using LINQ and it may take
I need generate thumbnails for a bunch of jpegs (200,000+) but I want to
I need generate action links outside controllers. I can use Html.Action in Views, Url.Action

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.