Score:0

Nginx to serve the same tiny image everytime

cn flag
Ram

I am using NGINX to serve a tracking pixel ( 1x1 image ) just to log the http call

Can I serve the image right from memory rather than having to serve a file

Jaromanda X avatar
ru flag
I hope this isn't the only thing you're doing with nginx, otherwise it's like using a sledgehammer to crack a nut
Score:2
br flag

As others have pointed out, Linux will do some file system caching automatically and your tiny file is very likely going to always fit nicely in that :) If you want to be extra sure about it, you could of course create a ram disk on system startup, mount it to the file system, copy your image file there and have Nginx serve its content from the ramdisk location. Basic instructions on how to do this can be found here: https://www.linuxbabe.com/command-line/create-ramdisk-linux

This will guarantee your file will always get delivered from ram and never be read from the disk, except at system startup.

Jonathan.Rosa avatar
gb flag
It's also worth noting that NGINX also has `open_file_cache` (allowable in location block) to keep the file descriptor open for this tiny file.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.