Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

Need to refresh page to see new content

         

Gemini23

12:45 pm on Dec 31, 2014 (gmt 0)

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



On my Wordpress installation (self hosted)homepage I have recent posts embedded into the page as well as other content. The website has news items and sometimes with fresh content several times a day. The problem is that to view latest added content I have to refresh the browser. This obviously isn't ideal as many visitors to the website return and may not think to refresh.
Is there a way to automaqtically show the updated page?

for info this is what is in the htaccess and I am not sure if related:

any help gratefully received..

<IfModule mod_expires.c>

ExpiresActive On

ExpiresByType image/jpg "access plus 1 year"

ExpiresByType image/jpeg "access plus 1 year"

ExpiresByType image/gif "access plus 1 year"

ExpiresByType image/png "access plus 1 year"

ExpiresByType text/css "access plus 1 month"

ExpiresByType application/pdf "access plus 1 month"

ExpiresByType text/x-javascript "access plus 1 month"

ExpiresByType application/x-shockwave-flash "access plus 1 month"

ExpiresByType image/x-icon "access plus 1 year"

ExpiresDefault "access plus 1 days"

</IfModule>

lorax

2:26 pm on Jan 1, 2015 (gmt 0)

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



Is caching setup in wp-config or do you have a caching plugin?

wslade

3:33 pm on Jan 1, 2015 (gmt 0)

10+ Year Member



Yes, I agree with lorax that the page may be cached from the server side. You will also want to make sure it is not also being cached by the browser. I would think adding "No Caching" to the index header would prevent both server side and browser caching. But research that before you believe me. :)

Disabling caching on the index page will slow down the page loading speed. After you stop caching the page, you will probably want to check the speed to make sure it is still acceptable. I would use tools.pingdom.com.

If you have no server side caching, your issue of missing content should only effect you and any returning visitors. A new visitor will have never seen the page, so would have nothing cached in their browser and would display the latest content.

Good luck with your new content.

Gemini23

3:40 pm on Jan 1, 2015 (gmt 0)

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



Thanks both

Re "Is caching setup in wp-config or do you have a caching plugin? "
I don't now the answer the first part but no caching plugin.
The thing is that there is a health percentage of return visitors - and wanting to see what is new etc... and unless they refresh they may well reasonably consider that there is nothing new....

wslade

4:45 pm on Jan 1, 2015 (gmt 0)

10+ Year Member



My guess is that you have no server side caching. You can see if there is a 'WP_CACHE', true in wp-config. If there is a cache setting, you can remove it. (I would remark that line out versus removing it - at least until you see how it works without the setting.)

My main plugin handles the No Cache headers for my site, so I haven't had to do anything to disable the browser cache. Do some searches for "disabling browser cache in wordpress". Or wait for someone to come along that knows more about browser caching than me.

Sorry I can't give you more concrete examples. I have a membership site and control of browser caching is so important to the overall site functionality that my membership plugin handles the browser cache on a page by page basis.

lucy24

7:04 pm on Jan 1, 2015 (gmt 0)

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



sometimes with fresh content several times a day

ExpiresDefault "access plus 1 days"


These two things don't seem to go together. Why don't you set a longer default, and then declare a shorter one for specifically text/html?

Gemini23

7:22 pm on Jan 1, 2015 (gmt 0)

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



ExpiresDefault "access plus 1 days" not sure exactly what this does or how to set a shorter one for text?

lucy24

10:19 pm on Jan 1, 2015 (gmt 0)

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



ExpiresDefault "access plus 1 days"
sets an expiration date of 1 day (24 hours) in the future for all material, unless overridden by an ExpiresByType directive. The word "access" means "right now as you're reading this".

<IfModule> means that this part of your htaccess was imported from some other source. Once it's on your own site, you either have the module or you don't, so the envelope isn't needed. (Possible exception: if this section is within the WP boilerplate, beginning and ending with #comment lines about WordPress, it may be necessary to leave the envelope.)

Right now your expiration headers are:

ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"

= images can be cached for up to a year, though it's not likely an actual browser's cache will stick around for that long.

ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"

= scripts, stylesheets and some other stuff can be cached up to a month. (Careful with this! It can mean that if you make major changes to a site's "look", frequent visitors may be viewing new content with old stylesheets, so they don't see what you wanted them to see.)

ExpiresByType image/x-icon "access plus 1 year"


= let the icon sit around for a year. (I don't know if x-icon means favicon or something entirely different. Wouldn't be surprised if browsers just ignore this anyway.)

ExpiresDefault "access plus 1 days" 


= anything that's left over can be retained by the browser for up to one day but no longer.

If your content updates more frequently, you should set a shorter expiration time. The shortest possible is
ExpiresByType text/html "access"
ExpiresByType text/php "access"

which essentially means "make a fresh request every time". This means, for example, that if a user follows a link from page A to page B, and then returns to page A, the browser sends in a fresh request to the server for page A again. Otherwise the browser will probably just reload its cached page A. Normally you wouldn't do this on a live site.

You can set any time period you like; see Apache docs [httpd.apache.org] for permitted wording. You can be as precise as you want, down to the second:

ExpiresByType text/html "access plus 1 hours 14 minutes 57 seconds"
ExpiresByType text/php "access plus 2 hours 36 minutes 11 seconds"


All of this refers to actual, physical files, not URLs. If it's a WordPress site, the actual, physical file is almost always "index.php" so your "type" is "text/php".

Gemini23

11:09 pm on Jan 1, 2015 (gmt 0)

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



Thanks Lucy
I will give some careful thought as to what I should have... seems like quite a minefield.. essentially most posts stay as they are... with aa number of pages being updated every few weeks and the homepage updated daily and often several times a day..

Gemini23

1:43 pm on Jan 2, 2015 (gmt 0)

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



I have amemded to the following in htaccess which I don't know if is correct and if whether it has any effect on this problem..
The latest post (posted today) is stll not showing on the static homepage (with latest posts)either within the ppage or in the "recent posts" in the sdebar. There is also a script which is showing yesterday's date (search box) and these will be corect IF I manually refresh the page.

Any suggestions?

Code from htaccess

<IfModule mod_expires.c>

ExpiresActive On

ExpiresByType image/jpg "access plus 1 day"

ExpiresByType image/jpeg "access plus 1 day"

ExpiresByType image/gif "access plus 1 day"

ExpiresByType image/png "access plus 1 day"

ExpiresByType text/css "access plus 1 hours"

ExpiresByType application/pdf "access plus 1 hours"

ExpiresByType text/x-javascript "access plus 1 hours"

ExpiresByType application/x-shockwave-flash "access plus 1 hours"

ExpiresByType image/x-icon "access plus 1 hours"

ExpiresByType text/html "access plus 1 hours 1 minutes 1 seconds"

ExpiresByType text/php "access plus 1 hours 1 minutes 1 seconds"

ExpiresDefault "access plus 1 hours"

</IfModule>

wslade

3:45 pm on Jan 2, 2015 (gmt 0)

10+ Year Member



Why not go a different direction and give this a try:
<HTML>
<HEAD>
<TITLE>---</TITLE>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD>
<BODY>
Put it in the html of the index page before the /head. I have not tried it but it should be quick and easy to add and test.

I hope it works for you...