The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Ultimate htaccess Article, Questions regarding said article
John Pozadzides
post Dec 13 2006, 12:45 AM
Post #1


WDG Founder
******

Group: Root Admin
Posts: 529
Joined: 3-August 06
From: Magnolia, TX
Member No.: 2



I was reviewing this article and had some questions for the Apache experts. Since Liam, Daren and the other members of the WDG know all this crap I don't have to. :-)

I was considering making some of these changes to my htaccess file for my Wordpress installation and figured I ought to run it by you guys first...

According to the article, you can "Dramatically Speed up your site by implementing Caching!" The author provides the following code but doesn't explain what it means in english:
CODE
# MONTH
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

# WEEK
<FilesMatch "\.(js|css|pdf|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>

# DAY
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
Prevent Files image/file hotlinking and bandwidth stealing
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ http://www.askapache.com/legal.gif [R=302,L]
  • Am I to understand that this basically caches image files for a month, JS/CSS for a week and html for a day?
  • If so how does this affect the fact that Wordpress is entirely PHP driven? In other words, if I make changes to my PHP (which I do all the time) would it prevent me from seeing the changes immediately?
  • My site has more MB of images than RAM so what happens if the server runs out of RAM (it's Linux)?
  • What would happen if I were to theoretically change my CSS or something that was cached. Would the system know that and re-cache it or would you have to manually clear the cache somehow?

They also say you can "Prevent Files image/file hotlinking and bandwidth stealing" with the following:
CODE
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ http://www.askapache.com/legal.gif [R=302,L]

Is there any reason NOT do do this?

Finally, what's the ServerSignature and why would you want to turn it off?

Thanks,

John
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Dec 13 2006, 01:54 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



I thought ServerSignature was that bit a server identifies itself with in the headers but oviously not.
http://httpd.apache.org/docs/1.3/mod/core....serversignature

The guys behind http://www.askapache.com/ haven't read http://www.w3.org/Provider/Style/URI.html . Every darn hit in Google ends up at their error page. ninja.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Tom H.
post Dec 13 2006, 08:55 AM
Post #3


Advanced Member
****

Group: Members
Posts: 129
Joined: 24-August 06
Member No.: 14



Good explanations of caching are found, among other places, at http://www.mnot.net/cache_docs/. Too bad the article you read doesn't provide any background.

The techniques they give don't cause your server to cache, all they do is send additional information to proxy servers which may sit between your web server and the end clients. (Some ISPs and many companies use proxy servers to reduce bandwidth use and speed up content delivery to their users.)

Proxy servers are smart enough to not cache server-generated pages (such as your php pages). All the disk files (CSS, images, HTML) served from your site are candidates for caching. Those .htaccess directives send additional information to proxy servers to help them decide whether to cache and for how long. For files which are rarely modified, it's beneficial for everyone if they are cached for a long time, and you can encourage that behavior by sending explicit information rather then making them guess.

I encourage caching of larger static files (images and PDFs), and discourage caching of frequently modified static files (HTML pages with timely information.)

Unless you have a problem with "bandwidth stealing" I would disregard their hint for that, since every URL rewrite rule gives your server more work to perform.

And the server signature setting is really just a cosmetic matter of choice.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Peter1968
post Dec 13 2006, 08:18 PM
Post #4


Serious Coder
*****

Group: Members
Posts: 448
Joined: 23-September 06
Member No.: 213



I'd suggest outputting a 403 rather than redirect to an image for bandwidth leeching. It tells search engines the right things as well as the dude using your images/URL on his/her site.

As for Tom H's advice re: giving the server more work, I'd argue that's what the server is there for, isn't it? I'd rather save 3-4Gb in bandwidth a month rather than hurt Apache's feelings by giving it an extra 2-3% overhead. Make it earn its keep.

Secondly, mod_rewrite is a pretty cleanly written beast and what ever the extra work there is will be minimal, especially if your site is the only thing that lives on the box.

CODE

Prevent Files image/file hotlinking and bandwidth stealing


That's needs to be commented out obviously.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
John Pozadzides
post Dec 13 2006, 11:43 PM
Post #5


WDG Founder
******

Group: Root Admin
Posts: 529
Joined: 3-August 06
From: Magnolia, TX
Member No.: 2



Thanks for all the great explanations guys. They help me better understand what's going on there.

I'm still uncertain if I should even worry about doing these at all. It sounds like none of it will make much of a difference since my personal site is on my own personal dedicated server that is WAY underutilized.

John
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
askapache
post Dec 29 2006, 12:50 PM
Post #6


Newbie
*

Group: Members
Posts: 18
Joined: 29-December 06
From: USA
Member No.: 1,407



Man you were so close!

I wrote an entire separate article on that code that you posted above.. you can read in its entirety on askApache.com If that article doesn't answer your questions let me know!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
askapache
post Mar 30 2007, 05:09 PM
Post #7


Newbie
*

Group: Members
Posts: 18
Joined: 29-December 06
From: USA
Member No.: 1,407



BTW John the link to the article is now http://www.askapache.com/2006/htaccess/apache-htaccess.html
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Mar 31 2007, 01:12 PM
Post #8


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



See also Cool URIs don't change
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
askapache
post May 31 2007, 09:47 PM
Post #9


Newbie
*

Group: Members
Posts: 18
Joined: 29-December 06
From: USA
Member No.: 1,407



Nice article Darin, I guess my url isn't cool smile.gif
http://www.askapache.com/htaccess/apache-htaccess.html
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post May 31 2007, 10:56 PM
Post #10


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



And your CSS seems rather bizarre. Do you expect line-height:.75em to improve the readability of your lists of links?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
askapache
post Jun 1 2007, 12:03 AM
Post #11


Newbie
*

Group: Members
Posts: 18
Joined: 29-December 06
From: USA
Member No.: 1,407



Yeah my CSS is due for a complete overhaul.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
askapache
post Sep 20 2008, 05:44 AM
Post #12


Newbie
*

Group: Members
Posts: 18
Joined: 29-December 06
From: USA
Member No.: 1,407



Yo Darin McGrew,

I just finished upgrading the CSS for my website, which you can check out at http://www.askapache.com/


Main style sheet, at http://z.askapache.com/z/c/apache-12.css

Print style sheet, at http://z.askapache.com/z/c/apacheprint-12.css

Let me know if I should change anything else!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Sep 20 2008, 10:14 AM
Post #13


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE
Let me know if I should change anything else!
Looking at the main style sheet, the thing that jumps out is the use of px for font sizes. Use a font size of 100% for body text, use larger percentages for headings and the like, and use (slightly) smaller percentages for legalese and similar fine print.

Also, the W3C CSS Validator reports some CSS errors.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
askapache
post Sep 20 2008, 03:54 PM
Post #14


Newbie
*

Group: Members
Posts: 18
Joined: 29-December 06
From: USA
Member No.: 1,407



Thanks Darin, its always nice to get some feedback! I just finished combining my main css file with my print css file, and verified the new single css file is CSS 2.1 warning free!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 21 2008, 02:17 AM
Post #15


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



There is a CSS forum where you can post questions about your CSS.
http://forums.htmlhelp.com/index.php?showforum=11
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 23rd April 2024 - 05:07 PM