ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Template access counting as two hits

December 31, 2008 11:00am

Subscribe [2]
  • #1 / Dec 31, 2008 11:00am

    municipal

    165 posts

    I’m sure it’s me doing something silly but when I’m on my main gallery page which displays category links and I click on one of the links to view the photos in that category, it’s counting as two template hits instead of one. The log file also shows just one access. What should I look for in my code that I might have messed up?

    Hmmm…wait a sec’...even if I strip out everything except EE stuff, it happens. This is the only thing in the template (slimmed down even further):

    {exp:gallery:entries gallery="poo" orderby="date" sort="asc" columns="5" limit="100"}
    
    <table class="thumbsall" cellpadding="0" cellspacing="0">
    {entries}
    {row_start}<tr>{/row_start}
    {row}<td><a href="http://{image_url}"><a href="{thumb_url}mTbIHqSsFPFUnLAi0KUYrTjPplMRiDO7typography_img_src_end width={thumb_width}_height={thumb_height} alt= ">{thumb_url}mTbIHqSsFPFUnLAi0KUYrTjPplMRiDO7typography_img_src_end width={thumb_width}_height={thumb_height} alt= </a></a></td>{/row}
    {row_blank}<td> </td>{/row_blank}{row_end}</tr>{/row_end}
    {/entries}
    </table>
    {/exp:gallery:entries}

    Scratching my head…bewildered.

  • #2 / Dec 31, 2008 1:45pm

    Derek Jones

    7561 posts

    The above tag is on an empty template that you’re accessing directly in the URL with an entry id of an image, not embedded and there are no other tags?  And you’re talking about the template hit counter, and not the image view count, correct?  Finally, when you refer to the “log file”, are you referring to a server log?

  • #3 / Dec 31, 2008 2:23pm

    municipal

    165 posts

    I’m accessing it via this EE-generated link on my main gallery page:

    <a href="http://{category_path=gallery/lightbox}">{category}</a>

    ...which produces this:

    <a href="http://www.example.com/gallery/lightbox/C1/">http://www.example.com/gallery/lightbox/C1/</a>

    ...but it seems that if I stick in the segment “category” like so…

    <a href="http://www.example.com/gallery/lightbox/category/C1/">http://www.example.com/gallery/lightbox/category/C1/</a>

    ...the problem goes away and template hit is one, not two.


    There are no other tags and yes, I am referring to the template hit counter and server log.

    So what does this mean? I need to rename my “lightbox” template to “category?” Not the end of the world I suppose…

    EDITED TO ADD:
    This is using lightbox so now every time I click on an image thumbnail to view it inline within this same page, the template hit counter increases by one.

    EDITED TO ADD AGAIN (yeesh):
    It seems to only increase incorrectly in Explorer?? And that’s whether or not the template has the word “category” in it.

  • #4 / Dec 31, 2008 2:37pm

    Derek Jones

    7561 posts

    Sounds like IE is accessing it twice.  To completely eliminate an EE error from the equation, access the URL directly in the address bar, not from a clicked link.  The javascript being used, in conjunction with IE, sounds like the plausible cause.

  • #5 / Dec 31, 2008 2:53pm

    municipal

    165 posts

    It’s happening in Firefox too. W-T-F?? I access the template directly and template hits are increasing but not uniformly. Like, it appears template hits are one for one when accessing the URL so I guess this isn’t your problem, huh? Once you start clicking on thumbnails and cycling through some photos and then click to close the lightbox, the template count has sporadically increased. Crud. It’s slimbox which I love and was just ported to jQuery.

  • #6 / Dec 31, 2008 3:00pm

    Derek Jones

    7561 posts

    Hm, well, at least the problem is narrowed down?  Seems a little weird that it would be making two HTTP requests.  I’m not familiar with slimbox so I’m afraid I don’t have any helpful troubleshooting suggestions.

  • #7 / Dec 31, 2008 3:15pm

    municipal

    165 posts

    Okey dokey. Thanks for addressing this though. Much appreciated. Happy New Year to y’all.

  • #8 / Dec 31, 2008 4:04pm

    Derek Jones

    7561 posts

    No problem; I’ll leave the thread open while you work through it, in case you have additional questions, or can provide details on the final resolution which might benefit others making use of that script.

  • #9 / Jan 05, 2009 9:45am

    municipal

    165 posts

    I’m back…and stuck because I am having difficulty asking the developer of Slimbox2 the right questions.

    Here’s the back-and-forth we have had so far—can you help me convey to him that EE is “innocent?”

    ME:
    When you load the page containing slimbox 2, it counts as one template hit*. But when you start clicking on thumbnails to view the larger images inline, this increases the number of template hits. It’s different in Firefox vs. Explorer…Explorer seems to increase by one each time a thumbnail is clicked on while Firefox only increases the number of hits when the first thumbnail is clicked on.

    *template hit—> I’m using this within ExpressionEngine (EE) which is able to count and display the number of template accesses.

    For testing purposes, I have stripped everything out of the template and am not even generating the content dynamically so that would rule out EE, wouldn’t it? Like, it’s simple HTML caling 10 different images.

    SLIMBOX DUDE:
    I don’t know how Expression Engine works. I can just garantee you that Slimbox only makes HTTP requests for images preloading and display. If making an HTTP GET request on the image URL causes a counter script being triggered, that could explain it.

    ME:
    Chris—I don’t have any counter scripts. The only reason I mentioned that this was within ExpressionEngine was to explain where I am seeing an incremental increase in template hits. Is there any further info I can provide or something I should be looking for?

    SLIMBOX DUDE:
    I was referring to an ExpressionEngine script. I have no idea how EE counts templates hits. Slimbox is just a client-side javascript which makes a few HTTP requests to load images. I was suggesting that the image URL might be handled by an EE script instead of the HTTP server. Or maybe EE monitors clicks using a javascript which communicates with the backend. I don’t know.

  • #10 / Jan 05, 2009 12:13pm

    Pascal Kriete

    2589 posts

    municipal,

    Do you have an example where we can see this behavior?  If you are linking to an ExpressionEngine url instead of linking directly to the image it would explain the behavior you’re seeing.

  • #11 / Jan 05, 2009 12:25pm

    municipal

    165 posts

    I could PM you a link to the test template…?

  • #12 / Jan 05, 2009 1:19pm

    Pascal Kriete

    2589 posts

    municipal,

    What browser are you testing with?  I can duplicate in Firefox, but not in Safari.  It might be firebug making its own requests.

    That’s the only explanation I could come up with.  This is definitely not an EE problem as the images are served by the webserver, so I’m going to move it to General Discussion.  You may want to send the Lightbox developer the same link that you sent me.

  • #13 / Jan 05, 2009 1:31pm

    municipal

    165 posts

    I was testing it in WIN/FF and WIN/IE7…and WIN/IE7 was ratcheting up the template hits even more…like, with every click on a thumbnail (although not consistently).

    Is there a simple explanation I can use to describe to the developer how the template hits in EE are generated? That seems to have been what originally threw a wrench into my getting help from him ‘cause he didn’t even ask for a link or anything. I guess he is under the impression that there are other things—EE-related things—at work here which is not the case.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases