Community Forums › Forums › Archived Forums › Design Tips and Tricks › Auto refresh, Genesis header.php doc?
Tagged: auto refresh, cache, header, header.php, Refresh
- This topic has 10 replies, 3 voices, and was last updated 8 years ago by
hmistler.
-
AuthorPosts
-
January 24, 2017 at 7:34 am #199923
hmistler
MemberI have a Genesis site that has WooCommerce on it, and while everything is working perfectly, I've noticed that the main shop page does not refresh automatically. If an item sells, I have to manually refresh the page to see that the item is sold out. I cannot find any documentation with WooCommerce about auto refreshes, I had assumed that it was built in to the plugin. But I guess not, and it seems no one else has this problem! Wondering how I can get my shop page to refresh automatically every time I or someone else visits it, even if it's stored in the browser cache? I just really need the store to display up-to-date info everytime someone visits the page.
I read I could install code to my header.php file, but isn't that a Genesis file? Here's what I think I should add to it, correct me if I'm wrong (the shop page is an archive page called archive-product):
if(is_category( 'product' )) { echo '<META HTTP-EQUIV="REFRESH" CONTENT="5">' ; }
Is it ok to add this to the Genesis header.php doc? Or does anyone have any other ways that I can get the shop page to do an automatic refresh every few seconds or so? THANKS!!!
https://mossandblue.com/shopJanuary 24, 2017 at 7:48 am #199924Victor Font
ModeratorAre you caching your site? If so, remove the shop pages from the cache.
Do not add anything to any file in the Genesis Framework. If you must add a meta tag to the header, use the genesis_meta action in functions.php:
add_action( 'genesis_meta', 'product_meta_refresh_tag' ); function product_meta_refresh_tag() { if( is_category( 'product' ) ) { echo '<META HTTP-EQUIV="REFRESH" CONTENT="5">' ; } }
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?January 24, 2017 at 7:52 am #199925hmistler
MemberI had my hosting company remove caching from the site, but I notice that the site will still cache on my computer (in Chrome and Firefox), so is there something else I can do to remove caching from the site?
I will add the code you wrote to my functions.php file and see if that helps, thanks!
January 24, 2017 at 9:48 am #199933Erika
ParticipantHmistler,
Are you viewing your shop page in admin mode or from a logged out perspective? When I make edits to my site and try to view them in admin mode, sometimes they don't appear unless I manually refresh. But, from an outsider perspective, the changes are indeed there.
January 24, 2017 at 10:00 am #199934hmistler
MemberHi Erika - I am viewing it as an outsider. For example, I checked the site on my laptop in Chrome this morning, after knowing that one of the products sold over the weekend, and when I went to the page, it was still listing the product as in stock. After I manually refreshed, the product was then listed as sold out. So I want to make sure that anyone who visits the site semi-often will see the most updated shop page. I had my hosting provider turn off the caching plugin they use on Friday, and so it was frustrating to look at the site today in my browser and still see it not updated.
I added Victor's code to my functions.php - is there any way to tell if it's working and auto-refreshing?
January 24, 2017 at 10:56 am #199937Victor Font
ModeratorYou should see the meta tag in the header when you view the page source code in the browser. Something I just noticed. Keep in mind I simply wrapped your original code in a proper wrapper. The shop page in WooCommerce is not a category page, so is_category('product') won't work. Also, you have the refresh set to 5 seconds. By setting a refresh to this short of a time, you remove control of the page from the user.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?January 24, 2017 at 11:09 am #199939hmistler
MemberHmm, just looked through and don't see it in the source code on the page. Maybe I am missing it?
mossandblue.com/shopJanuary 24, 2017 at 11:16 am #199940Victor Font
ModeratorLike I said in my previous post, the conditional you've chosen for your code, is_category('product'), won't work on the shop page because it's not a category page. You need to use the WooCommerce is_shop() conditional. https://docs.woocommerce.com/document/conditional-tags/
Here's the corrected code:
add_action( 'genesis_meta', 'product_meta_refresh_tag' ); function product_meta_refresh_tag() { if( is_shop() ) { echo '<META HTTP-EQUIV="REFRESH" CONTENT="5">' ; } }
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?January 24, 2017 at 1:39 pm #199954hmistler
MemberVictor - sorry I had missed your previous post; I added the corrected code and it works perfectly now, thank you.
What is the normal rate for refresh for pages that might have ongoing changes (like Gmail, or larger ecommerce stores where products sell very quickly?) 30 seconds, one hour?
January 24, 2017 at 2:19 pm #199957Victor Font
ModeratorI don't have an answer for you on this question. I don't know of anyone that uses meta refresh any more. And truthfully, I've setup up a lot of WooCommerce sites but have never seen the issue you are experiencing the numbers.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?January 24, 2017 at 2:33 pm #199958hmistler
MemberWell everything with WooCommerce is working perfectly... it's just annoying that when I visit the shop page multiple times a day or hit the back button, sometimes the new info (if there is any) isn't displayed without a refresh. The way this shop sells is all about timing, as pieces are released at one time and sell quickly since there is a limited supply of only one product for each SKU. So it's important that anyone visiting the page sees the up-to-date info.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.