1

I am new to YOURLS and just set it up on nmdrp.me to be able to forward to my site, namedrop.io. For e.g. nmdrp.me/1.

The challenge I am trying to solve is that once I go to nmdrp.me/1 on my Chrome browser the first time, the Counter for the page goes +1. But then when I got to nmdrp.me/1 again after that from the same browser (no matter how many minutes later), the counter doesn't go up.

Bit.ly is able to pick up the next visit to the site from the same browser after 2 minutes.

I believe this is because there is a cookie set to not expire by default on nmdrp.me - and I want to change that.

Can you please tell me how to change the cookie.php to be able to set cookies that expire in 2 minutes, so I can also pick up the next visit on the same browser?

huysentruitw
  • 27,376
  • 9
  • 90
  • 133
credizian
  • 469
  • 5
  • 20

1 Answers1

1

Nothing to do with cookies - http://nmdrp.me/1 serves a 301 redirect. 301 redirects (being "permanent") are cached by the browser - subsequent visits to the same URL will be served from the cache rather than your server, meaning no more cicks counted.

There are a few places in the codebase you'll need to change if you want this adjusted.

edit: Bit.ly uses a header, Cache-Control: private, max-age=90, to address this with their 301s to limit the cache to 90 seconds.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368
  • So is Bit.ly using 302 redirects? I was reading that's not recommended because with 302 you don't get link attribution credit. Is there no other way? Clear the cache for nmdrp.me host? – credizian Aug 13 '15 at 19:48
  • 1
    @credizian Bit.ly appears to send `Cache-Control: private, max-age=90` with their 301 redirects to fix this, which you could try as well. – ceejayoz Aug 13 '15 at 19:54
  • would you know where I would indicate this in the code? – credizian Aug 13 '15 at 20:02
  • @credizian Adjust the `yourls_redirect` function. You'll need to add another `header()` call in there. – ceejayoz Aug 13 '15 at 20:11
  • will try this out. Not sure how to yet, but I understand what you asked me to do. :) Ty! – credizian Aug 13 '15 at 20:19
  • Old thread but, for posterity, I just want to state that there are several YOURLS plugins available to deal with this. *Never* "adjust" functions (ie edit core code) if you can have a separate plugin do the desired task. – Ozh May 14 '16 at 14:36