Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

Caching problem?

         

Gemini23

3:10 pm on Jan 27, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi,

I have a website with daily updates – up until a week or so ago - when new content was posted the homepage would automatically display the new content – ie if leaving the homepage and going back and typing the url in a browser the new content would be displayed.

The homepage consists of Post titles linking to the posts with a brief snippet…

Now… the only way new content can be seen is by ‘refreshing’ the url… ie in Chrome and clicking the refresh button.

Hosted on Siteground with their SG Caching - which I have 'excluded the homepage but it doesn't make any difference...

I am not technically minded enough to know the answer but I wonder if any of these settings in the htaccess file are causing the issue?

# Leverage Browser Caching by SG-Optimizer
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 2 months"
# CSS
ExpiresByType text/css "access plus 1 year"
# HTML components (HTCs)
ExpiresByType text/x-component "access plus 2 months"
# HTML
ExpiresByType text/html "access plus 2 months"
# JavaScript
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-javascript "access plus 1 year"
# Manifest files
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Media
ExpiresByType audio/ogg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/svg "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/ogg "access plus 1 year"
ExpiresByType video/webm "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType application/pdf "access plus 1 year"
ExpiresByType application/x-shockwave-flash "access plus 1 year"
# Web feeds
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
# Web fonts
ExpiresByType application/font-woff "access plus 1 year"
ExpiresByType application/font-woff2 "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType font/opentype "access plus 1 year"
</IfModule>

Any help greatly appreciated.

lammert

5:47 pm on Jan 27, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You should look at the actual headers the server is sending to the browser. In Firefox this is relatively easy by pressing the F12 button and then manually reloading the page. Under the network tab you select the URL you want to inspect and the headers sent with that URL can be checked in the adjacent window. Look for anything which specifiy expiration times, cache use etc.

WebmasterWorld also has tools to check server headers at [freetools.webmasterworld.com...] but unfortunately, these tools are currently unavailable due to some technical glitches.

Looking at your config, this line is probably causing the long caching period for the page:
ExpiresByType text/html "access plus 2 months"

Gemini23

6:45 pm on Jan 27, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks - I have amended the ExpiresByType text/html "access plus 2 months" - to 60 seconds but it didn't make any difference.

lammert

6:53 pm on Jan 27, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Did you check in your browser which headers are now actually sent with the page?

Amit_Aggar

5:15 am on Jan 28, 2020 (gmt 0)

5+ Year Member



Now… the only way new content can be seen is by ‘refreshing’ the url… ie in Chrome and clicking the refresh button.


This is happen because you have set the cache value above "1 year"

If you are using apache. Open .htaccess and add these lines:

<filesMatch “.(ico|pdf|flv|jpg|jpeg|png|gif|svg|js|css|swf)$”>
Header set Cache-Control “max-age=600, public”
</filesMatch>

Or you could hire a web developer that will help you

phranque

6:51 am on Jan 28, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If you are using apache. Open .htaccess and add these lines:

this will only affect the headers sent with responses to requests for those file types.

as lammert pointed out, this is most likely the relevant configuration directive:
ExpiresByType text/html "access plus 2 months"


Did you check in your browser which headers are now actually sent with the page?

this is where i would start looking.

not2easy

1:02 pm on Jan 28, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



<filesMatch “.(ico|pdf|flv|jpg|jpeg|png|gif|svg|js|css|swf)$”>
Header set Cache-Control “max-age=600, public”
</filesMatch>

Whatever else you decide to do, do not (DO NOT!) use these lines for this purpose. There is nothing whatever in there that might change the cache control for any page on your site but it will definitely increase the bandwidth usage for page loads because it removes caching of .js, .css and all image files.

If for some reason you cannot check the headers of your home page as it loads, I would ask your host whether they can help since the caching is provided by
Siteground with their SG Caching
and we can only guess at how that should be configured.

Gemini23

2:08 pm on Jan 29, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The problem has been fixed by editing the htaccess file - curious that it appeared to be working beforehand - unless the Siteground SG Optimizer edited the htaccess from its settings.