Use less bandwidth, serve faster pages, and less Apache processing time!

Started by Joshua Dickerson, July 10, 2007, 12:21:44 PM

Previous topic - Next topic

Joshua Dickerson

How many of you have caching enabled? Hopefully, more than a few. If you don't, talk to your host about installing mod_headers or mod_expires. According to Firebug this post page has 17KB of images, 90KB of javascript, and 20KB of CSS. That is 127KB of data that doesn't have to be loaded on every page view. Let's say you get 100,000 page views a month. That equates to 12GB of saved bandwidth a month (assuming none of it gets cached).

Here goes a tutorial on what to do: http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html

I would make the default for images, css, and javascript a day or even a week if you don't do many changes. For larger things like movies, flash, etc. I would make it much longer. For PHP files, I wouldn't even cache them.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

!Hachi!

on  our front page we chnage imgs  like daily but css stays there so theme files are...should we proceed?
Happy Ramadan

Joshua Dickerson

you can still cache the CSS. You can even cache the images, if only for a day or a couple of hours.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

H

-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

!Hachi!

i ahve one simple question.for example i add jpeg or any type of img for 1 week then i modify those images.will it display before expiring as it will extract it from cache rather than from the original source.
    same thing with css i will put it for 1 week even for 1 month as i don't touch it but what if i add something will it read from main source?
  i have mod_expires installed only.
Happy Ramadan

Joshua Dickerson

It still sends headers which are tiny bits of text that tell the user when the last time it was modified. It should then update the user's cache. It might not always do that though. Sometimes, a hard refresh is required or the cached item needs to expire (either will work).
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

!Hachi!

i am testing on local machine just want to confirm everything in it.few questions ...
1.How much time will it take to cache them all?like user will access it and apache will add it to cache?
2.how about server load as it will increase apache activity (cache....sending requests to refresh etc.)?
one more question i am using seo4smf mod so all pages comes in .html so should i add html pages also>? confuse here.
Happy Ramadan

Joshua Dickerson

The browser caches it. When you visit the page, your browser downloads all 'parts' of the page and caches based on headers.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

!Hachi!

Groundup  thanks for your reply.
    i am on VPS so i can access every file.i try to add to checkthings up but apache file (httpd.conf) is messed up when ever i restart it.
i added these codes


<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A86400       
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A604800
ExpiresByType application/x-shockwave-flash A604800
</IfModule>

       am i missing something here?i can't get it work.need your guide
Regards.
Hassan.
Happy Ramadan


!Hachi!

update*
              make changes in script and its works.great results.
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/jpg "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType text/html "access 1 day"
ExpiresDefault "access 2 days"
</IfModule>
     don't know why it hates 1st method its working fine now.
Happy Ramadan

青山 素子

If you have the ability to do so (basically, a dedicated or VPS), turning off htaccess will speed things up on a busy server. When Apache has overrides allowed, it has to search the whole tree from the current directory to the web root for any of those files, and does so for each file. It isn't much, but two or three access attempts per file on a busy server does add up.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.



Advertisement: