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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:55:11+00:00 2026-06-12T21:55:11+00:00

There are about 10 files in a directory called assets which are required by

  • 0

There are about 10 files in a directory called “assets” which are required by by various img tags in the main layout on the browser.

10 separate requests are sent to get the separate tiny image files.
(eventually i will optimise this to just send one request to load a single image sheet consisting of all images in one)

But its sometimes unable to load all of them, so the browser shows the spinning/loading icon for ages till it timesout or it loads them but they are a wrong order/match (img tag will display a wrong image) or it just doesnt load the image, its a different behaviour everytime i refresh the page

//first request gzips and loads the main layout, subsequent requests loads images

require('fs').readFile('assets/'+params.file, function(err, data) {
  if(err) throw err;
  if(params.file == 'layout.html') {
  require('zlib').gzip(data, function(err, buffer) {
    if(err) throw err;
    output(buffer, params);        
   });
  } else output(data, params);
});


function output(data, params){ 
  switch(params.file.substring(params.file.length-3)) {
    case 'tml': params.headers = {'Content-Encoding': 'gzip'};break;
    case 'ico': params.headers = {'Content-Type': 'image/x-icon'};break;
    case 'ttf': params.headers = {'Content-Type': 'application/x-font-ttf' }; break;
    case 'otf': params.headers = {'Content-Type':'font/opentype'};break;
    case 'png': params.headers = {'Content-Type':'image/png'};break;
    case 'gif': params.headers = {'Content-Type':'image/gif'};break;
    case 'peg':
    case 'jpg': params.headers = {'Content-Type':'image/jpeg'};break;
    default: params.headers = {};
  }
  params.headers['Set-Cookie'] =  '';       
  params.responseOutput(data, params);
}

this feels a little like those pesky “closure” problems, but there are no forloops here and each image request from the browser should not interfere with another (..and yet it is)

  • 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-06-12T21:55:13+00:00Added an answer on June 12, 2026 at 9:55 pm

    The fact that some requests sometimes serve the wrong file suggests that you do have a closure issue, most likely involving params getting changed before either the readfile or gzip callbacks execute. What’s its scope and how do you construct it (another possibility is that params itself is properly scoped, but it contains references to something that isn’t)?

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

Sidebar

Related Questions

So, there seems to be a few questions asking about removing files/directories matching certain
Although there are a lot of posts about .net config files, I believe that
I have a mysql database in which there is about hundreds of category for
My question is about test files by which I mean non-code files on which
Starting with a .csproj which defines various xml Content files. Have code generation Target
In my home directory, I have a folder called local . In it, there
I have a few things in various different files that get called from different
I have the following two questions about emacs In my .emacs.d directory there is
I have a huge log file where there are about 15 million lines. I
Is there a workaround to stop Update-FormatData complaining about a loaded file when the

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.