Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Robert Walker
17,146 Pointscache and PHP
Been looking around for any sort of help or videos on cache and PHP but cant seem to find any, are there any available here at Treehouse?
If there are I would love the links, if not does anyone know of any good sources to look at till Treehouse does one?
Ive watched a few youtube videos and read a few articles from around the web but I don't really get a good understanding of how its done right.
Any help would be amazing thank you in advance.
Robert Walker
17,146 PointsThanks for your reply haunguyen but what I am looking for is more of a tutorial on how to use cache and store things like images on a users browser cache.
Iam currently working on a small project that has around 100 images load on a single page, every time I refresh the page or go back to it at some point I am having to download those images yet again, so I am looking to store these images on the end users browser for say 24 hours before they would need to download them again.
Im totally new to the cache and how it would work and am looking for something I can watch / read that will explain it all to me and the best way to use it so I don't fall into the trap of caching things I really shouldn't.
1 Answer
thomascawthorn
22,986 PointsI'm guessing if they're taking so long to load / you're worried about bandwidth, these are images of quite a large size? You could look into techniques of reducing the size of images e.g. creating thumbnails?
how to use cache and store things like images on a users browser cache.
Browsers will already automatically cache (and here) images, so you might not even need to do anything there.
If it were me, I would lazy load images via ajax :-)
haunguyen
14,985 Pointshaunguyen
14,985 PointsCache is more of a server issue than a coding issue, so it may not integrate well with php lessons.
From experience, APC is probably easiest opcode cache to configure and run. There are a few online guides that are easy to follow, the hardest part is to convince yourself not to worry about breaking the server and just try to install and run the cache.
APC cache automatically caches php opcodes. AND you can also use create cache variables to store data, for example, you can store a text file in a cached variable and bypass the I/O cost of reading that file from disk.
If you have xampp or mapp installed on your local machine, adding apc cache should be an easy practice.