G1 built in caching hack.
iturgeon
Joined: 2004-07-21
Posts: 7 |
Posted: Tue, 2007-03-13 18:42 |
I have a client that uses g1.5.4(They want the direct image linking ability). They have high traffic with 3k+ images on a shared host (dreamhost). The site was dropping to useless during high load. Sometimes completely unresponsive main page, and 15s+ album pages. I kept pushing g2 because of its better handeling of large galleries and built in caching, but their workflow relies on directly linking to the images, so I looked into optimizing g1. I looked at http://codex.gallery2.org/Gallery1:Performance_Tips. They didn't have huge albums, although the page doesn't define what a "large album" is. They werent using the album tree, but were using the accurate photo count item. I turned off any and all frivolous features that didn't have to do with uploading and displaying photos. It was still crawling. I looked to the suggested crontab caching technique next. It worked, and the main page loaded quickly. However randomly throughout the day, the cache file would be 0 bytes and the gallery would be just as useless again. So I took to the code, and added a built in caching technique. I added caching to albums.php and view-album.php. It supports multi-page main pages and album pages, rebuilds the caches automatically and has kept g1 useable on the current host for my client. I thought I'd share the caching code so the others out there that have to or must use g1 can hopefully use it. I haven't spent any time beautifying, but the code is working.. album.php: and at the bottom: |
|
Posts: 6818
Hello,
can you provide a unified diff ?
thanks,
Jens
--
Last Gallery v1 Developer and v1 translation manager.
Posts: 13451
Also, you can do direct linking in G2 as well?
h0bbel - Gallery Team
If you found my help useful, please consider donating to Gallery
http://h0bbel.p0ggel.org
Posts: 6818
True! forget my post.
Move over to G2.
Jens
--
Last Gallery v1 Developer and v1 translation manager.
Posts: 7
There are various reasons they want to use g1, but can you point me in the direction of whatever it is I need to do direct image linking (not through url rewrite or using the protection of the g2 DownloadItem module)?
Posts: 32509
speaking of g2...
> (not through url rewrite or using the protection of the g2 DownloadItem module)?
what's the problem with mod_rewrite? the URLs look like normal static image URLs with it... and direct linking is no problem at all.
and performance isn't a big factor. with g2's fast-download cache (always enabled), core.DownloadItem requests are very fast.
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage