Forum: NGINX How to make empty_gif expire image immediately?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Rt Ibmer (Guest)
on 2008-10-30 05:37
(Received via mailing list)
Hi,

I'm using empty_gif to make a request to a log file for tracking
purposes (as a beacon).  How can I configure nginx so that the browser
is instructed to expire the image immediate (or just to not cache it to
begin with).

I tried this:

        location /files/beacon.gif {
                access_log /tracking.log main;
                expires 0;
                empty_gif;
        }

However when I look at the browser internals for the empty gif it is
marked to expire in 1 day instead of 0.  For instance my http analyzer
shows the image is set to expire on October 30, 2008 which is one day
from now. What am I missing? Thanks!
Dave C. (Guest)
on 2008-10-30 06:10
(Received via mailing list)
try this

location = /files/beacon.gif {
    return 204;
}

see a similar example here:

lucky:~ dcheney$ curl -I http://deadwood.cheney.net/v1
HTTP/1.1 204 No Content
Server: nginx
Date: Thu, 30 Oct 2008 04:01:50 GMT
Connection: keep-alive

Cheers

Dave


On Wed, 29 Oct 2008 20:28:06 -0700 (PDT), Rt Ibmer 
<removed_email_address@domain.invalid>
wrote:
> Hi,
>
> I'm using empty_gif to make a request to a log file for tracking purposes
> (as a beacon).  How can I configure nginx so that the browser is
instructed
> However when I look at the browser internals for the empty gif it is
marked
> to expire in 1 day instead of 0.  For instance my http analyzer shows the
> image is set to expire on October 30, 2008 which is one day from now.
What
Rt Ibmer (Guest)
on 2008-10-30 06:38
(Received via mailing list)
So is the idea here that you don't send any image? My concern with that
is the I would think that under some circumstances some browsers may try
more than once to get the image if it got a 204, which would then cause
too many hits to the log (throw off the tracking).

I may try this out but I am still very interested to hear why the
expires 0 does not seem to have an effect with empty_gif. Thanks.
Dave C. (Guest)
on 2008-10-30 07:18
(Received via mailing list)
> So is the idea here that you don't send any image? My concern with that
is
> the I would think that under some circumstances some browsers may try
more
> than once to get the image if it got a 204, which would then cause too
many
> hits to the log (throw off the tracking).

Why would they try twice? Only if the href was referenced more than once
on
the page. A 204 is guarenteed by the RFC to be uncachable

> > I may try this out but I am still very interested to hear why the
expires 0
> does not seem to have an effect with empty_gif. Thanks.

http://wiki.codemongers.com/NginxHttpHeadersModule#expires

exipres 0 means Expires: the current date

Which is probably subject to clock skew.

Try

expires epoch;

Cheers

Dave
Sean A. (Guest)
on 2008-11-04 00:42
(Received via mailing list)
On Oct 29, 2008, at 11:28 PM, Rt Ibmer wrote:

>                access_log /tracking.log main;
>                expires 0;
>                empty_gif;
>        }
>
> However when I look at the browser internals for the empty gif it is
> marked to expire in 1 day instead of 0.  For instance my http
> analyzer shows the image is set to expire on October 30, 2008 which
> is one day from now. What am I missing? Thanks!

expires -1;

works like a charm for me.
This topic is locked and can not be replied to.