All times are UTC + 5:30 hours




Post new topic Reply to topic  [ 6 posts ] 
  Print view

Image/Thumbnail Cache Busting
Author Message
PostPosted: Fri Mar 23, 2012 9:04 pm 
Registered User
Offline

Joined: Thu Oct 13, 2011 2:48 am
Posts: 258
I have a root htaccess file with:
Code:
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 0 seconds"
ExpiresByType image/jpeg "access plus 2 weeks"
</IfModule>
Lets say I have a clonable template with an 'image' and associated 'thumbnail' editable region. I upload the image. The 'image' is initially requested as: 'image.jpg' and the 2 week expires is sent with it. I hit save on the cloned page. The page reloads, and the 'thumbnail' is requested as: 'image-200x100.jpg' and the 2 week expires is also again sent with it. At this stage even if the 'image' file has been resized, my browser will continue to use the original cached 'image.jpg' as expected. Similarly, for the 'thumbnail' file after selecting a different 'crop position', my browser will continue to use the original cached 'image-200x100.jpg' as expected after saving the cloned page. On thumbnail recreation, I can see that couch utilizes a 'rand' querystring to bust any present cache-control. However this will as expected not effect the non-querystring version.

I know a simple refresh will result in the updated image and thumbnail files being sent, but I can't expect my client knowing when to do that. Without turning off expires for my '/uploads/image/' folder, can I get around this? Is there a way I could apply "access plus 0 seconds" or a redirect to a random querystring'ed version based on the referrer being from my couch directory? Hopefully I am missing a simple solution.

Oh... and Google's reCAPTCHA: http://www.google.com/recaptcha. It would be nice to be able to use that, as I am reluctant to use couch's captcha partially because it reveals the location of the couch directory through the captcha image.

** Sorry, accidentally posted this in the wrong section. You can move it if you like.


Top
 Profile  
 

Re: Image/Thumbnail Cache Busting
PostPosted: Sat Mar 24, 2012 11:42 pm 
Moderator
Offline

Joined: Wed Dec 01, 2010 5:35 pm
Posts: 1378
Can't see any straightforward way of doing this.
Apache 2.3 has an <If>..</If> directive (http://httpd.apache.org/docs/trunk/mod/core.html#if). Perhaps that could be used to check for the referrer and then conditionally use the 'ExpiresByType' directive. Haven't tested this out, though.


Top
 Profile  
 

Re: Image/Thumbnail Cache Busting
PostPosted: Wed Apr 04, 2012 12:36 am 
Registered User
Offline

Joined: Thu Oct 13, 2011 2:48 am
Posts: 258
The host I'm using at the moment is running Apache 2.2. The 'if' directive does sound promising for this situation nevertheless. I'm not sure it's the route you would like to take, but if all 'image' and 'thumbnail' editable regions in the admin panel were generated with the 'rand' query string, caching could be prevented. I see this as more preferable than disabling caching for the 'uploads/image' folder.

On a side note, I think it would be a good idea to have some sort of visual indicator on the template sidebar of the number of un-approved comments. This would prevent people from needing to click on the comments sidebar item to see if there are any new comments. In addition, I think it would be neat to be able to specify a custom image for each template in the sidebar. This would be similar to how 'Comments', 'Users', and clonable templates display a 16x16 image to the left of their respective text title.

** Edit: I meant to say the use of cached images could be avoided, not that caching could be avoided.


Last edited by cheesypoof on Wed Apr 04, 2012 1:37 am, edited 1 time in total.

Top
 Profile  
 

Re: Image/Thumbnail Cache Busting
PostPosted: Wed Apr 04, 2012 1:27 am 
Moderator
Offline

Joined: Wed Dec 01, 2010 5:35 pm
Posts: 1378
I'll definitely look into if adding the random value helps.

As for the new comments indicator - I have been trying to get myself do that for a long time now :)
The sidebar is also due for a make-up - allowing grouping of templates, separator between templates and now, as suggested by you, the icons.
Hopefully the next version should have all these in.


Top
 Profile  
 

Re: Image/Thumbnail Cache Busting
PostPosted: Fri Apr 27, 2012 3:45 am 
Registered User
Offline

Joined: Thu Oct 13, 2011 2:48 am
Posts: 258
In retrospect the icons may have been a silly request, considering the fact that CSS can do this quite easily while allowing for even greater flexibility/customization than a static icon would.

Attachment:
navigation-icons.jpg
navigation-icons.jpg [ 13.14 KiB | Viewed 746 times ]

couch/theme/styles.css:
Code:
.templates a[title="404.php"]{background:url(images/icons/page-error.png) no-repeat 43px 7px}

.templates>.active-template>a[title="404.php"]{background:url(images/icons/page-error.png) no-repeat 43px 7px,url(images/arrow.gif) no-repeat scroll 15px 3px}

Icons courtesy: http://led24.de/iconset/
You could also try: http://famfamfam.com/lab/icons/silk/


Last edited by cheesypoof on Sun Dec 23, 2012 7:02 am, edited 1 time in total.

Top
 Profile  
 

Re: Image/Thumbnail Cache Busting
PostPosted: Sat Apr 28, 2012 12:35 pm 
Registered User
Offline

Joined: Thu Oct 13, 2011 2:48 am
Posts: 258
Nevermind... The title attribute for the navigation links is only generated for the super admin. There doesn't appear to be any way to target them for normal administrators with the current markup. Feature request? :P Perhaps some attribute that is consistent across all user levels. It doesn't even really have to be something functional like a title, it could just be a class or the rel attribute.

** Final Correction :lol:
CSS3 has some new selectors that can make this work:
Code:
For clonable templates use this method:
.templates a[href$="tpl=5"]

For non-clonable templates use this method:
.templates a[href*="tpl=5&"]
Replace 5 with your template number.


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 5:30 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© 2001-2010 SYS-Solutions All Rights Reserved