Advertisement:

Author Topic: Use less bandwidth, serve faster pages, and less Apache processing time!  (Read 9482 times)

Offline Joshua Dickerson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,665
  • Gender: Male
    • joshuaadickerson on LinkedIn
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.
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?

Offline !Hachi!

  • SMF Hero
  • ******
  • Posts: 1,666
  • Gender: Male
    • pakurdu.net
on  our front page we chnage imgs  like daily but css stays there so theme files are...should we proceed?
Happy Ramadan

Offline Joshua Dickerson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,665
  • Gender: Male
    • joshuaadickerson on LinkedIn
you can still cache the CSS. You can even cache the images, if only for a day or a couple of hours.
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?

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,656
  • Gender: Male
Sticked this as it is a useful topic :)
Huw
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Offline !Hachi!

  • SMF Hero
  • ******
  • Posts: 1,666
  • Gender: Male
    • pakurdu.net
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

Offline Joshua Dickerson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,665
  • Gender: Male
    • joshuaadickerson on LinkedIn
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).
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?

Offline !Hachi!

  • SMF Hero
  • ******
  • Posts: 1,666
  • Gender: Male
    • pakurdu.net
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.
« Last Edit: July 29, 2007, 09:02:02 AM by hassan »
Happy Ramadan

Offline Joshua Dickerson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,665
  • Gender: Male
    • joshuaadickerson on LinkedIn
The browser caches it. When you visit the page, your browser downloads all 'parts' of the page and caches based on headers.
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?

Offline !Hachi!

  • SMF Hero
  • ******
  • Posts: 1,666
  • Gender: Male
    • pakurdu.net
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
Code: [Select]

<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

Offline haco

  • Newbie
  • *
  • Posts: 4
thank you very much

Offline !Hachi!

  • SMF Hero
  • ******
  • Posts: 1,666
  • Gender: Male
    • pakurdu.net
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

Offline 青山 素子

  • Server Team
  • SMF Super Hero
  • *
  • Posts: 16,483
  • 戦場ヶ原、蕩れ!
    • motokochan on GitHub
    • @motokochan on Twitter
    • Animeneko Network
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

Just like... making of enemies / 負ける気しない やめるきない / You are cool but fool - Charisma.com 『HATE』

Note: I am not a member of the Simple Machines Forum project.


Offline hamade_ima

  • Newbie
  • *
  • Posts: 6
Re: Use less bandwidth, serve faster pages, and less Apache processing time!
« Reply #12 on: August 01, 2007, 06:08:19 AM »
thanks