homepage Welcome to WebmasterWorld Guest from 54.204.215.209
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
How to configure caching in httpd.conf file in Apache server 2.2
caching configuration in Apache server 2.2
kiran009




msg:4627733
 10:10 am on Dec 4, 2013 (gmt 0)

Hello All,
I am new to Apache server configurations
I am trying to get the static files(images, css, js) files through Apache,

we want to maintain the images and css files in the cache for a while,
in order to do that i have place the following configuration in httpd.conf file

i have google and place this code in httpd.conf file
and i dont have .htaccess filein my apache server.

LoadModule expires_module modules/mod_expires.so

<IfModule mod_expires.c>

<FilesMatch "\.(jpe?g|png|gif|js|css)$">
ExpiresActive On
ExpiresDefault "access plus 1 week"
</FilesMatch>

# 2days
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=172800, public"
</FilesMatch>

</IfModule>

is it the one i need to place or can some one give some suggestions how to maintain cache and
how to test the caching is working on browsers.

[edited by: phranque at 8:45 pm (utc) on Dec 4, 2013]
[edit reason] no specifics please [/edit]

 

phranque




msg:4627891
 8:54 pm on Dec 4, 2013 (gmt 0)

welcome to WebmasterWorld, kiran009!


do your HTTP Responses for the cacheable resources include the Expires and Cache-Control headers with expected values?

the Google Page Speed and Yahoo Yslow browser plugins will give you some information about cache headers for the resources on a given page.

kiran009




msg:4628251
 4:28 am on Dec 6, 2013 (gmt 0)

Thanks for replay Phranque,

i did not get fully, but have read somewhere about the mod_mem cache and mod_disck cache, is it any useful to configure in apache httpd conf file, and i still did not get how to test my configuration changes of httpd.conf file, whether i have place the proper configurations or not.

phranque




msg:4628262
 5:50 am on Dec 6, 2013 (gmt 0)

all of your configuration directives are about browser caching and proxy server caching.
you have to look at the response headers after sending appropriate request headers (such as If-Modified-Since).
one easy method of examining the headers is to use the Google Page Speed and/or Yahoo Yslow browser plugins.


mod_mem_cache and mod_disk_cache are storage managers used by apache's mod_cache module to handle local or proxy caching by the web server.
your Expires and Cache-Control response headers may be used by mod_cache if you have it configured but those are end-to-end headers, so you don't necessarily need mod_cache to get some benefit.

kiran009




msg:4628340
 2:03 pm on Dec 6, 2013 (gmt 0)

Hi phranque,

We have cross checked on our http headers , i do not find any

'if modified since'. we are wondering how to configure it on Apache to enable this respose headers.

please give me some suggestions how to do this.

Thanks in advance
Kiran.

JD_Toims




msg:4628442
 8:02 pm on Dec 6, 2013 (gmt 0)

The "if-modified-since", "if-match", "if-none-match", etc. headers are sent along with a request for a page by the browser [user-agent] -- They're not headers sent by your server.

What Phranque was meaning is your server needs to be configured to properly send Expires and/or Cache-Control when a page is originally requested by a user-agent. Then when the user-agent re-requests the same page and sends an "if-modified-since" header your server must respond properly with a 304 Not Modified header, if: The expires date is not passed and/or the cache-control time has not passed.

Keep in mind: if a cache-control header contains a max-age, then the cache-control max-age will override the date sent in the expires header, meaning if both are set and they're not the same, then compliant user-agents will use the cache-control max-age rather than the expires date.

phranque




msg:4628451
 8:32 pm on Dec 6, 2013 (gmt 0)

Kiran, have you tried using Google Page Speed and/or Yahoo Yslow?

kiran009




msg:4628899
 5:01 am on Dec 9, 2013 (gmt 0)

Hello phranque,

I have tried the google page speed plugin , and it has shown some suggestions to improve the areas to optimize the performance, here is the report given by the plugin:


Click on the rule names to see suggestions for improvement.

Reduce blocking resources
(M)Inline Small CSS, (L)Inline Small JavaScript, (L)Optimize the order of styles and scripts
Minimize payload
(H)Enable compression, (M)Minify CSS, (M)Minify JavaScript, (L)Optimize images, (L)Minify HTML
Minimize delay in page load
(L)Specify image dimensions
Other
(H)Leverage browser caching, (M)Defer parsing of JavaScript, (L)Specify a cache validator, (L)Remove query strings from static resources, (L)Specify a Vary: Accept-Encoding header

so we are wondering how we can enable cache on browser through apache2.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved