Author Topic: Cache & images  (Read 2016 times)

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,133
  • Reputation: +26/-1
    • View Profile
Cache & images
« on: January 23, 2010, 05:43:16 AM »
Drop here all tips & info regarding improving images speed, size, etc.

Theory (lenghty): http://www.mnot.net/cache_docs/

Image optimizers (requirements: free, downloadable, can process images in batch):
PNG http://psydk.org/PngOptimizer.php (very nice to use, it reduced size of images in one of my games by almost 50%)
GIF ???
JPG ???


Question: What would be the simpliest way of setting all images to be expired no sooner than after one week after last visit?

Offline Nox

  • Level 35
  • **
  • Posts: 738
  • Reputation: +12/-2
    • View Profile
Re: Cache & images
« Reply #1 on: January 23, 2010, 06:00:51 AM »
XnView drops size a lot, although it's not exactly optimizer
JPG&PNG&(probably)GIF: SmushIt (Yahoo)....not downloadable though
PNGCrush, but only commandline
damn.... every one has a catch :)

I think YSlow displays if images are to expire soon...

Misread the question.... take a look at http://www.askapache.com/ there are tons of things you can do with htaccess counting expire time, eTags etc.

As stated in YSlow and Yahoo's website performance tips it's also good to use sprites (many images placed to one)
to reduce requests and their overhead and waiting times, sometimes the size can be smaller too... in case that the image is only visible on hover
it's not loaded with page and without sprite upon first hover there can be delay between hover and loading the image with only background,
even if only as a flicker.

The price is sometimes more work in CSS/HTML (sometimes less), and some work considering gathering those images, more difficult to maintain/modify
It doesn't have to be 1 image sprite per site, but it's useful in case of icons or menu for example
« Last Edit: January 23, 2010, 09:29:55 AM by Nox »
Meet us at an IRC irc.freenode.net #bbg as well
Enjoy http://spiritbeacon.noxart.cz/ !

Offline aquilax

  • Level 5
  • *
  • Posts: 20
  • Reputation: +1/-0
    • View Profile
    • Internet games
Re: Cache & images
« Reply #2 on: January 23, 2010, 07:58:05 AM »
Question: What would be the simpliest way of setting all images to be expired no sooner than after one week after last visit?

The easiest way should be to use Apache with mod_expires (http://httpd.apache.org/docs/2.0/mod/mod_expires.html):

Code: [Select]
ExpiresDefault "access plus 1 week"

Offline aquilax

  • Level 5
  • *
  • Posts: 20
  • Reputation: +1/-0
    • View Profile
    • Internet games
Re: Cache & images
« Reply #3 on: January 23, 2010, 08:01:21 AM »
If you want to go deeper into optimization, you should check Stoyan Stefanov's blog (http://www.phpied.com/) and especially the performance calendar for 2009: http://www.phpied.com/performance-advent-calendar-2009/ . Stoyan is also the author of SmushIt.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,133
  • Reputation: +26/-1
    • View Profile
Re: Cache & images
« Reply #4 on: January 23, 2010, 09:30:20 AM »
Question: What would be the simpliest way of setting all images to be expired no sooner than after one week after last visit?

The easiest way should be to use Apache with mod_expires (http://httpd.apache.org/docs/2.0/mod/mod_expires.html):

Code: [Select]
ExpiresDefault "access plus 1 week"
Apache mod is not for me. Can't it be done via CSS/HTML?

Offline Nox

  • Level 35
  • **
  • Posts: 738
  • Reputation: +12/-2
    • View Profile
Re: Cache & images
« Reply #5 on: January 23, 2010, 09:36:38 AM »
I'm quite certain that not...
Meet us at an IRC irc.freenode.net #bbg as well
Enjoy http://spiritbeacon.noxart.cz/ !

Offline aquilax

  • Level 5
  • *
  • Posts: 20
  • Reputation: +1/-0
    • View Profile
    • Internet games
Re: Cache & images
« Reply #6 on: January 23, 2010, 10:40:48 AM »
Apache mod is not for me. Can't it be done via CSS/HTML?

HTML and CSS no, PHP yes but it's still ineffective.

ST-Mike

  • Guest
Re: Cache & images
« Reply #7 on: January 23, 2010, 11:27:23 AM »
Admins have ignored my deletion request - if you're not going to delete my account then don't have the option there please.
« Last Edit: March 15, 2011, 07:49:51 PM by None »

Offline aquilax

  • Level 5
  • *
  • Posts: 20
  • Reputation: +1/-0
    • View Profile
    • Internet games
Re: Cache & images
« Reply #8 on: January 23, 2010, 11:33:12 AM »
Mike: maybe he is on free hosting and some of them doesn't allow custom .htaccess

Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: Cache & images
« Reply #9 on: January 24, 2010, 04:50:47 AM »
Best would be if images could be "saved" as a cookie on user end, and javascript would be able to reproduce the image from the cookie contents...

Can it be done?
I suppose not, but who knows..
You could then set an expire time, and all your images would be only downloaded once.




ST-Mike

  • Guest
Re: Cache & images
« Reply #10 on: January 24, 2010, 09:43:20 AM »
Admins have ignored my deletion request - if you're not going to delete my account then don't have the option there please.
« Last Edit: March 15, 2011, 07:49:43 PM by None »

ST-Mike

  • Guest
Re: Cache & images
« Reply #11 on: January 24, 2010, 09:44:43 AM »
Admins have ignored my deletion request - if you're not going to delete my account then don't have the option there please.
« Last Edit: March 15, 2011, 07:49:39 PM by None »

Offline tellmore

  • Level 12
  • *
  • Posts: 85
  • Reputation: +3/-0
    • View Profile
Re: Cache & images
« Reply #12 on: January 24, 2010, 09:52:00 AM »
Well, did not know coockies gets sent back :D Strange, I don't see the logic why is that.

in that case this is not an option.

:D




ST-Mike

  • Guest
Re: Cache & images
« Reply #13 on: January 24, 2010, 10:06:12 AM »
Admins have ignored my deletion request - if you're not going to delete my account then don't have the option there please.
« Last Edit: March 15, 2011, 07:48:30 PM by None »

Offline aquilax

  • Level 5
  • *
  • Posts: 20
  • Reputation: +1/-0
    • View Profile
    • Internet games
Re: Cache & images
« Reply #14 on: January 24, 2010, 01:48:46 PM »
Hmmmmm although it is possible to store images in CSS even in HTML (http://tools.ietf.org/html/rfc2397) , i don't think it's worth it. Especially for bigger images.

Offline bbgames

  • Level 16
  • *
  • Posts: 138
  • Reputation: +1/-0
    • View Profile
    • Building Browsergames
Re: Cache & images
« Reply #15 on: January 24, 2010, 02:33:27 PM »
Question: What would be the simpliest way of setting all images to be expired no sooner than after one week after last visit?

Why do you want to expire one week after last access? While you'd technically be caching things, you could do much better.

Personally, the best way I've seen caching done has been using far-future expiry dates(say, 10 years from now) - and then if you need to update any of your media, you change the URL. You can do this pretty easily by using a cache buster or by versioning your media, the way that Particletree does it - they've explained how here.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,133
  • Reputation: +26/-1
    • View Profile
Re: Cache & images
« Reply #16 on: January 25, 2010, 04:36:37 AM »
Quote
and then if you need to update any of your media, you change the URL.
I do not want to change anything, no modification of files, names, serious code changes, etc. Was looking for something that would just make the images to be reloaded a bit rarer since the game I want to use it for is after development phase and don't need such frequent gfx updates.

How do I find if I have certain Apache mod installed?

If I use htaccess how will it affect performance? These need to check all files before accessing? How it will treat scripts already cached by eAccelerator?

Offline Nox

  • Level 35
  • **
  • Posts: 738
  • Reputation: +12/-2
    • View Profile
Re: Cache & images
« Reply #17 on: January 25, 2010, 05:00:31 AM »
I'm quite sure the performance cost would be almost none.... it also doesn't check anything, it just sets a few headers for a browser to handle caching

I think the mod should be in by default, but I just use the WAMP solution, makes things easier
Meet us at an IRC irc.freenode.net #bbg as well
Enjoy http://spiritbeacon.noxart.cz/ !

Offline jannesiera

  • Level 35
  • **
  • Posts: 1,026
  • Reputation: +6/-1
    • View Profile
    • BBGameDesign
Re: Cache & images
« Reply #18 on: January 25, 2010, 10:30:56 AM »
I'm quite sure htaccess does nothing to performance. Only if you're using multiple .htaccess files or doing some really have routing or something like that.

ST-Mike

  • Guest
Re: Cache & images
« Reply #19 on: January 25, 2010, 11:31:14 AM »
Admins have ignored my deletion request - if you're not going to delete my account then don't have the option there please.
« Last Edit: March 15, 2011, 07:46:34 PM by None »

Offline bbgames

  • Level 16
  • *
  • Posts: 138
  • Reputation: +1/-0
    • View Profile
    • Building Browsergames
Re: Cache & images
« Reply #20 on: January 25, 2010, 12:42:25 PM »
Are you serving your media off of an Apache server? You might see better results by moving your media to a different setup entirely - Amazon Cloudfront, Rackspace's Cloudfiles, or an nginx server that only serves your media (all of these options using far-future caching, of course).

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,133
  • Reputation: +26/-1
    • View Profile
Re: Cache & images
« Reply #21 on: February 26, 2010, 09:31:06 AM »
So, anyone found a good GIF, JPG optimizer? We need these two for our collection to be complete :D

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal