Home User profile
tagDiv Member
This user did not write anything. So we are just showing here some random text to make the profile page look nice :)
cantoute
tagDiv Member

Hi,

Thank you for investigating.
I did some research too and pretty sure the problem is in the way it is managed by the theme. We have no issue with any other Ajax requests (including other WP projects using CF + Rest + GraphQL).
In the meantime I found a work around.
There is a setting in CloudFlare in the Cache section to set a rule to bypass cache in presence of a cookie. This way the authors can navigate in the site without the “loader” jamming 🙂

I still hope the devs find the fix, would be nice for others too.
But what would be even nicer is that those requests could use GET … opening the magics of cache <3
Saturday http://www.welovetennis.fr hit over 1 million visits… not easy to handle such load without cache.

Fingers crossed 🙂
Thanks for reading and wish you all a nice day.

reminder: in previous messages, logs confirmed that the POST request did get to the backend and that it was the backend responding 403, not cf.

  • This reply was modified 3 years by cantoute.
cantoute
tagDiv Member

BTW

Are they aware that one can install and run it’s private GitLab ?

I suffer for you guys working all year long using this editor ?

cantoute
tagDiv Member

When using a cache plugin in WordPress (aka W3-TotalCache or other), it will disable the cache for authenticated users and build the page for all known users.

But when using ClouFlare, when page is in cache, admin users get same page as everybody.

So navigating on the frontend of the site admins have time to time the wordpress admin-bar (cf cache miss) and no admin-bar (cf cache HIT)

So when admins do have the admin bar the infinite scroll works as expected, but on pages without the admin-bar (cf cache HIT) the Ajax request reaches the server and bounces status 403.

Bellow you’ll find the request in curl
If I run that request without the line “-H ‘cookie’ … ” it works just fine.
So I believe the payload / ‘–data-raw’ section holds something about the authenticated user that has to match the cookie, and that when it finds the cookie and not the relevant data in the payload, the request gets rejected.
(I’ve tested all I could. Things like disabling any security plugins like Wordfence etc..)


curl 'https://www.welovetennis.fr/wp-admin/admin-ajax.php?td_theme_name=Newspaper&v=12.3.1' \
-H 'authority: www.welovetennis.fr' \
-H 'accept: */*' \
-H 'accept-language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,es-419;q=0.6,es;q=0.5' \
-H 'content-type: application/x-www-form-urlencoded; charset=UTF-8' \
-H 'cookie: wordpress_sec_f1bdf72b037f4fc61a63ad5e89e9ef25=antony%7C1686083014%7CURpjXWj39EjnJJRGKPumlEmrKcrFlVet04mQNF1ntDn%7C4856477bbdf40dcf110a94ce8fe959667a535a667b2568634a269f62cd4dfb87; wordpress_logged_in_f1bdf72b037f4fxxxxxxxxxx25=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxf6fb09ef8ae5; wp-settings-1=editor%3Dhtml%26libraryContent%3Dbrowse%26advImgDetails%3Dshow%26posts_list_mode%3Dlist%26imgsize%3Dfull%26mfold%3Do; wp-settings-time-1=1684873423; fonce_current_user=1; _ga_1Z908S1EE2=GS1.1.1685172078.1.0.1685172078.0.0.0; _pbjs_userid_consent_data=1688550979652389; _gid=GA1.2.1338529052.1685759630; hidecta=no; _ga_98EFBCYPM8=GS1.1.1685759629.9.1.1685759860.0.0.0; cto_bundle=8djCU19DMGVlRWxiSUdyMVQ2M0hDa3BwQ05BYmNHQnFIcEFHTFU3VzhlWkdQbDlndVNmb3FKb0JOT1ZGUkhzciUyQlQ5MHBnb1dRNGIyTFdEMTBFd0lCM25tclZaNUFJZXRuY3FSSktJdkJLNzFvSSUyRlJqZyUyRkRYbVhPckhISlZ3aUNOaVNvMnJCZHBOdVZGR0FsSlFwJTJGU1pYek0lMkZnJTNEJTNE; cto_bidid=_sEKgV82RWp4YkNYZWFVejBnTXNHVG0yOUgxcHRhSXZEa0lwdEFEalJTdU93ZDglMkZQYVFkOGhTWHRRbjdvdDJRRk5SZSUyRlV0dmpSOVpXTDZYM0dySmhwUHdmbmNWNHpkYmpuV211OXJpYVlYYmtVWGNkaGJtQk5KNklueHNaN3hxTWhNMjU; _ga=GA1.2.1020367004.1684952847; _gat=1' \
-H 'dnt: 1' \
-H 'origin: https://www.welovetennis.fr' \
-H 'referer: https://www.welovetennis.fr/' \
-H 'sec-ch-ua: "Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Linux"' \
-H 'sec-fetch-dest: empty' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-site: same-origin' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36' \
-H 'x-requested-with: XMLHttpRequest' \
--data-raw 'action=td_ajax_block&td_atts=%7B%22art_title_pos%22%3A%22bottom%22%2C%22info_pos%22%3A%22bottom%22%2C%22art_excerpt_pos%22%3A%22bottom%22%2C%22art_audio_pos%22%3A%22bottom%22%2C%22modules_category%22%3A%22image%22%2C%22btn_pos%22%3A%22bottom%22%2C%22modules_on_row%22%3A%22eyJhbGwiOiI1MCUiLCJwaG9uZSI6IjEwMCUiLCJwb3J0cmFpdCI6IjEwMCUifQ%3D%3D%22%2C%22category_ids%22%3A%22346%22%2C%22limit%22%3A%224%22%2C%22ajax_pagination%22%3A%22infinite%22%2C%22sort%22%3A%22%22%2C%22offset%22%3A%223%22%2C%22ajax_pagination_infinite_stop%22%3A%223%22%2C%22tdc_css%22%3A%22eyJwaG9uZSI6eyJkaXNwbGF5IjoiIn0sInBob25lX21heF93aWR0aCI6NzY3fQ%3D%3D%22%2C%22show_btn%22%3A%22%22%2C%22td_ajax_preloading%22%3A%22%22%2C%22show_review%22%3A%22none%22%2C%22show_com%22%3A%22none%22%2C%22time_ago_add_txt%22%3A%22%22%2C%22block_type%22%3A%22td_flex_block_5%22%2C%22separator%22%3A%22%22%2C%22custom_title%22%3A%22%22%2C%22custom_url%22%3A%22%22%2C%22block_template_id%22%3A%22%22%2C%22title_tag%22%3A%22%22%2C%22mc5_tl%22%3A%22%22%2C%22mc5_title_tag%22%3A%22%22%2C%22mc5_el%22%3A%22%22%2C%22post_ids%22%3A%22%22%2C%22category_id%22%3A%22%22%2C%22taxonomies%22%3A%22%22%2C%22in_all_terms%22%3A%22%22%2C%22tag_slug%22%3A%22%22%2C%22autors_id%22%3A%22%22%2C%22installed_post_types%22%3A%22%22%2C%22open_in_new_window%22%3A%22%22%2C%22show_modified_date%22%3A%22%22%2C%22time_ago%22%3A%22%22%2C%22time_ago_txt_pos%22%3A%22%22%2C%22el_class%22%3A%22%22%2C%22td_query_cache%22%3A%22%22%2C%22td_query_cache_expiration%22%3A%22%22%2C%22td_ajax_filter_type%22%3A%22%22%2C%22td_ajax_filter_ids%22%3A%22%22%2C%22td_filter_default_txt%22%3A%22All%22%2C%22modules_gap%22%3A%22%22%2C%22m_padding%22%3A%22%22%2C%22all_modules_space%22%3A%2236%22%2C%22modules_border_size%22%3A%22%22%2C%22modules_border_style%22%3A%22%22%2C%22modules_border_color%22%3A%22%23eaeaea%22%2C%22modules_divider%22%3A%22%22%2C%22divider_on%22%3A%22%22%2C%22modules_divider_color%22%3A%22%23eaeaea%22%2C%22h_effect%22%3A%22%22%2C%22image_size%22%3A%22%22%2C%22image_alignment%22%3A%2250%22%2C%22image_height%22%3A%22%22%2C%22image_radius%22%3A%22%22%2C%22image_margin%22%3A%22%22%2C%22hide_image%22%3A%22%22%2C%22video_icon%22%3A%22%22%2C%22video_popup%22%3A%22yes%22%2C%22video_rec%22%3A%22%22%2C%22spot_header%22%3A%22%22%2C%22video_rec_title%22%3A%22%22%2C%22video_rec_color%22%3A%22%22%2C%22video_rec_disable%22%3A%22%22%2C%22autoplay_vid%22%3A%22yes%22%2C%22show_vid_t%22%3A%22block%22%2C%22vid_t_margin%22%3A%22%22%2C%22vid_t_padding%22%3A%22%22%2C%22video_title_color%22%3A%22%22%2C%22video_title_color_h%22%3A%22%22%2C%22video_bg%22%3A%22%22%2C%22video_overlay%22%3A%22%22%2C%22vid_t_color%22%3A%22%22%2C%22vid_t_bg_color%22%3A%22%22%2C%22f_vid_title_font_header%22%3A%22%22%2C%22f_vid_title_font_title%22%3A%22Video+pop-up+article+title%22%2C%22f_vid_title_font_settings%22%3A%22%22%2C%22f_vid_title_font_family%22%3A%22%22%2C%22f_vid_title_font_size%22%3A%22%22%2C%22f_vid_title_font_line_height%22%3A%22%22%2C%22f_vid_title_font_style%22%3A%22%22%2C%22f_vid_title_font_weight%22%3A%22%22%2C%22f_vid_title_font_transform%22%3A%22%22%2C%22f_vid_title_font_spacing%22%3A%22%22%2C%22f_vid_title_%22%3A%22%22%2C%22f_vid_time_font_title%22%3A%22Video+duration+text%22%2C%22f_vid_time_font_settings%22%3A%22%22%2C%22f_vid_time_font_family%22%3A%22%22%2C%22f_vid_time_font_size%22%3A%22%22%2C%22f_vid_time_font_line_height%22%3A%22%22%2C%22f_vid_time_font_style%22%3A%22%22%2C%22f_vid_time_font_weight%22%3A%22%22%2C%22f_vid_time_font_transform%22%3A%22%22%2C%22f_vid_time_font_spacing%22%3A%22%22%2C%22f_vid_time_%22%3A%22%22%2C%22meta_info_horiz%22%3A%22content-horiz-left%22%2C%22meta_width%22%3A%22%22%2C%22meta_margin%22%3A%22%22%2C%22meta_margin2%22%3A%22%22%2C%22meta_padding%22%3A%22%22%2C%22meta_padding2%22%3A%22%22%2C%22meta_info_border_size%22%3A%22%22%2C%22meta_info_border_size2%22%3A%22%22%2C%22meta_info_border_style%22%3A%22%22%2C%22meta_info_border_color%22%3A%22%23eaeaea%22%2C%22meta_info_border_radius%22%3A%22%22%2C%22meta_info_border_radius2%22%3A%22%22%2C%22info_space%22%3A%22%22%2C%22art_title%22%3A%22%22%2C%22show_excerpt%22%3A%22block%22%2C%22art_excerpt%22%3A%22%22%2C%22excerpt_inline%22%3A%22%22%2C%22meta_space%22%3A%22%22%2C%22show_audio%22%3A%22block%22%2C%22hide_audio%22%3A%22%22%2C%22art_audio%22%3A%22%22%2C%22art_audio_size%22%3A%221.5%22%2C%22show_cat%22%3A%22inline-block%22%2C%22modules_category_margin%22%3A%22%22%2C%22modules_category_padding%22%3A%22%22%2C%22modules_category_border%22%3A%22%22%2C%22modules_category_radius%22%3A%220%22%2C%22modules_extra_cat%22%3A%22%22%2C%22show_author%22%3A%22inline-block%22%2C%22author_photo%22%3A%22%22%2C%22author_photo_size%22%3A%22%22%2C%22author_photo_space%22%3A%22%22%2C%22author_photo_radius%22%3A%22%22%2C%22show_date%22%3A%22inline-block%22%2C%22review_space%22%3A%22%22%2C%22review_size%22%3A%222.5%22%2C%22review_distance%22%3A%22%22%2C%22btn_title%22%3A%22%22%2C%22btn_margin%22%3A%22%22%2C%22btn_padding%22%3A%22%22%2C%22btn_border_width%22%3A%22%22%2C%22btn_radius%22%3A%22%22%2C%22pag_space%22%3A%22%22%2C%22pag_padding%22%3A%22%22%2C%22pag_border_width%22%3A%22%22%2C%22pag_border_radius%22%3A%22%22%2C%22prev_tdicon%22%3A%22%22%2C%22next_tdicon%22%3A%22%22%2C%22pag_icons_size%22%3A%22%22%2C%22f_header_font_header%22%3A%22%22%2C%22f_header_font_title%22%3A%22Block+header%22%2C%22f_header_font_settings%22%3A%22%22%2C%22f_header_font_family%22%3A%22%22%2C%22f_header_font_size%22%3A%22%22%2C%22f_header_font_line_height%22%3A%22%22%2C%22f_header_font_style%22%3A%22%22%2C%22f_header_font_weight%22%3A%22%22%2C%22f_header_font_transform%22%3A%22%22%2C%22f_header_font_spacing%22%3A%22%22%2C%22f_header_%22%3A%22%22%2C%22f_ajax_font_title%22%3A%22Ajax+categories%22%2C%22f_ajax_font_settings%22%3A%22%22%2C%22f_ajax_font_family%22%3A%22%22%2C%22f_ajax_font_size%22%3A%22%22%2C%22f_ajax_font_line_height%22%3A%22%22%2C%22f_ajax_font_style%22%3A%22%22%2C%22f_ajax_font_weight%22%3A%22%22%2C%22f_ajax_font_transform%22%3A%22%22%2C%22f_ajax_font_spacing%22%3A%22%22%2C%22f_ajax_%22%3A%22%22%2C%22f_more_font_title%22%3A%22Load+more+button%22%2C%22f_more_font_settings%22%3A%22%22%2C%22f_more_font_family%22%3A%22%22%2C%22f_more_font_size%22%3A%22%22%2C%22f_more_font_line_height%22%3A%22%22%2C%22f_more_font_style%22%3A%22%22%2C%22f_more_font_weight%22%3A%22%22%2C%22f_more_font_transform%22%3A%22%22%2C%22f_more_font_spacing%22%3A%22%22%2C%22f_more_%22%3A%22%22%2C%22f_title_font_header%22%3A%22%22%2C%22f_title_font_title%22%3A%22Article+title%22%2C%22f_title_font_settings%22%3A%22%22%2C%22f_title_font_family%22%3A%22%22%2C%22f_title_font_size%22%3A%22%22%2C%22f_title_font_line_height%22%3A%22%22%2C%22f_title_font_style%22%3A%22%22%2C%22f_title_font_weight%22%3A%22%22%2C%22f_title_font_transform%22%3A%22%22%2C%22f_title_font_spacing%22%3A%22%22%2C%22f_title_%22%3A%22%22%2C%22f_cat_font_title%22%3A%22Article+category+tag%22%2C%22f_cat_font_settings%22%3A%22%22%2C%22f_cat_font_family%22%3A%22%22%2C%22f_cat_font_size%22%3A%22%22%2C%22f_cat_font_line_height%22%3A%22%22%2C%22f_cat_font_style%22%3A%22%22%2C%22f_cat_font_weight%22%3A%22%22%2C%22f_cat_font_transform%22%3A%22%22%2C%22f_cat_font_spacing%22%3A%22%22%2C%22f_cat_%22%3A%22%22%2C%22f_meta_font_title%22%3A%22Article+meta+info%22%2C%22f_meta_font_settings%22%3A%22%22%2C%22f_meta_font_family%22%3A%22%22%2C%22f_meta_font_size%22%3A%22%22%2C%22f_meta_font_line_height%22%3A%22%22%2C%22f_meta_font_style%22%3A%22%22%2C%22f_meta_font_weight%22%3A%22%22%2C%22f_meta_font_transform%22%3A%22%22%2C%22f_meta_font_spacing%22%3A%22%22%2C%22f_meta_%22%3A%22%22%2C%22f_ex_font_title%22%3A%22Article+excerpt%22%2C%22f_ex_font_settings%22%3A%22%22%2C%22f_ex_font_family%22%3A%22%22%2C%22f_ex_font_size%22%3A%22%22%2C%22f_ex_font_line_height%22%3A%22%22%2C%22f_ex_font_style%22%3A%22%22%2C%22f_ex_font_weight%22%3A%22%22%2C%22f_ex_font_transform%22%3A%22%22%2C%22f_ex_font_spacing%22%3A%22%22%2C%22f_ex_%22%3A%22%22%2C%22f_btn_font_title%22%3A%22Article+read+more+button%22%2C%22f_btn_font_settings%22%3A%22%22%2C%22f_btn_font_family%22%3A%22%22%2C%22f_btn_font_size%22%3A%22%22%2C%22f_btn_font_line_height%22%3A%22%22%2C%22f_btn_font_style%22%3A%22%22%2C%22f_btn_font_weight%22%3A%22%22%2C%22f_btn_font_transform%22%3A%22%22%2C%22f_btn_font_spacing%22%3A%22%22%2C%22f_btn_%22%3A%22%22%2C%22mix_color%22%3A%22%22%2C%22mix_type%22%3A%22%22%2C%22fe_brightness%22%3A%221%22%2C%22fe_contrast%22%3A%221%22%2C%22fe_saturate%22%3A%221%22%2C%22mix_color_h%22%3A%22%22%2C%22mix_type_h%22%3A%22%22%2C%22fe_brightness_h%22%3A%221%22%2C%22fe_contrast_h%22%3A%221%22%2C%22fe_saturate_h%22%3A%221%22%2C%22m_bg%22%3A%22%22%2C%22shadow_shadow_header%22%3A%22%22%2C%22shadow_shadow_title%22%3A%22Module+Shadow%22%2C%22shadow_shadow_size%22%3A%22%22%2C%22shadow_shadow_offset_horizontal%22%3A%22%22%2C%22shadow_shadow_offset_vertical%22%3A%22%22%2C%22shadow_shadow_spread%22%3A%22%22%2C%22shadow_shadow_color%22%3A%22%22%2C%22meta_bg%22%3A%22%22%2C%22meta_bg2%22%3A%22%22%2C%22title_txt%22%3A%22%22%2C%22title_txt_hover%22%3A%22%22%2C%22all_underline_height%22%3A%22%22%2C%22all_underline_color%22%3A%22%23000%22%2C%22cat_bg%22%3A%22%22%2C%22cat_bg_hover%22%3A%22%22%2C%22cat_txt%22%3A%22%22%2C%22cat_txt_hover%22%3A%22%22%2C%22cat_border%22%3A%22%22%2C%22cat_border_hover%22%3A%22%22%2C%22author_txt%22%3A%22%22%2C%22author_txt_hover%22%3A%22%22%2C%22date_txt%22%3A%22%22%2C%22ex_txt%22%3A%22%22%2C%22com_bg%22%3A%22%22%2C%22com_txt%22%3A%22%22%2C%22rev_txt%22%3A%22%22%2C%22shadow_m_shadow_header%22%3A%22%22%2C%22shadow_m_shadow_title%22%3A%22Meta+info+shadow%22%2C%22shadow_m_shadow_size%22%3A%22%22%2C%22shadow_m_shadow_offset_horizontal%22%3A%22%22%2C%22shadow_m_shadow_offset_vertical%22%3A%22%22%2C%22shadow_m_shadow_spread%22%3A%22%22%2C%22shadow_m_shadow_color%22%3A%22%22%2C%22audio_btn_color%22%3A%22%22%2C%22audio_time_color%22%3A%22%22%2C%22audio_bar_color%22%3A%22%22%2C%22audio_bar_curr_color%22%3A%22%22%2C%22btn_bg%22%3A%22%22%2C%22btn_bg_hover%22%3A%22%22%2C%22btn_txt%22%3A%22%22%2C%22btn_txt_hover%22%3A%22%22%2C%22btn_border%22%3A%22%22%2C%22btn_border_hover%22%3A%22%22%2C%22pag_text%22%3A%22%22%2C%22pag_h_text%22%3A%22%22%2C%22pag_bg%22%3A%22%22%2C%22pag_h_bg%22%3A%22%22%2C%22pag_border%22%3A%22%22%2C%22pag_h_border%22%3A%22%22%2C%22ajax_pagination_next_prev_swipe%22%3A%22%22%2C%22css%22%3A%22%22%2C%22td_column_number%22%3A1%2C%22header_color%22%3A%22%22%2C%22color_preset%22%3A%22%22%2C%22border_top%22%3A%22%22%2C%22class%22%3A%22tdi_85%22%2C%22tdc_css_class%22%3A%22tdi_85%22%2C%22tdc_css_class_style%22%3A%22tdi_85_rand_style%22%7D&td_block_id=tdi_85&td_column_number=1&td_current_page=2&block_type=td_flex_block_5&td_filter_value=&td_user_action=&td_magic_token=3380c233f7' \
--compressed

  • This reply was modified 3 years by cantoute.
cantoute
tagDiv Member

It is not Clouflare returning error.

It seems the ajax call is authenticated (and being a POST not cache-able)
And that the request was built form a page stored in cache (from a not authenticated request)

I get this in the server logs:

xxx.xxx.xxx.xxx - - [03/Jun/2023:04:37:40 +0200] "POST www.welovetennis.fr/wp-admin/admin-ajax.php?td_theme_name=Newspaper&v=12.3.1 HTTP/2.0" 403 22 "https://www.welovetennis.fr/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" 0.207 0.202 . -

cantoute
tagDiv Member

hi,

Isolated the problem.
It was a plugin “French Typo” that caused the problem…

Sorry for the noise.

Have a nice day.

cantoute
tagDiv Member

being here I had an other issue with the megamenu offsetting itself halfway threw the page when post had a tweet

this was the fix


/* fix megamenu offset when post has a tweet */
(function($){
    $(window).load(function() {
        $(this).trigger('resize')
    })
})(jQuery)
cantoute
tagDiv Member

and here i took things one step further but the result is almost copy paste for devs

Just you wouldn’t have to put debounce_ajax_call in ‘window’ context, I was forced to it because my context is .on(‘foncsin’) (out of tdAjaxSearch object)
so in this hack i just debounce the actual ajax request (and not the do_ajax_call) that is changed to ‘GET’ (and removing the setTimeout)

line 19 there is
tdAjaxSearch.process_ajax_response_mob(b)

if you change it to
tdAjaxSearch.process_ajax_response_mob(b, a) // a being here the search term

then in function process_ajax_response_mob() you have the term without having to read the response 🙂

https://pastebin.com/cL3SfhVf

I was just playing around to look for ways of making life easier in there.

hope it can help

  • This reply was modified 6 years by cantoute.
cantoute
tagDiv Member

The webiste I did with your theme has gone from small trafic to become nº1 in tennis in europe… thanks to your work !!

But that means that for Roland Garros I could have to handle over 500k daily visitors (we are yet over 70k)
It’s not that big… I have other site running 2M (not wp tho)
As the site uses infinit scroll… caching even of 3s would help

I coud suggest a very simple change that could change the deal about caching (the site is behind varnish)

php side have all ajax $_POST changed to $_REQUEST

then I could fiddle to change all ajax POST to { method:’GET’, cache:false }

it adds a &_=134567 that can be removed from url in varnish and then hit a common cache

… no rush, just clues 🙂

  • This reply was modified 6 years by cantoute.
cantoute
tagDiv Member

here problem solved…

the problem came from the “preloaded” megamenu that using template 3 from cloud templates and I couldn’t disable it.
Since then switched to theme headers and disabled preloading of the megamenu and the page weight dropped 🙂

cantoute
tagDiv Member

I finally found a way to hack it in… to give the server a breath

https://pastebin.com/LtvHqZM8

jQuery(function() {
jQuery('.tdb-head-search-form-input').on('keydown', function(e) {
if (typeof debounce_do_ajax_call === "undefined") {
console.log('tdbSearch.do_ajax_call override');

tdbSearch.original_td_do_ajax_call = tdbSearch.do_ajax_call;

// as hacked out of context, needed to hook context or debounce would trigger on each call
debounce_do_ajax_call = debounce(tdbSearch.original_td_do_ajax_call, 1500)

tdbSearch.do_ajax_call = debounce_do_ajax_call
}
});
});

// https://davidwalsh.name/javascript-debounce-function
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};

cantoute
tagDiv Member

looks a bit better here… sorry for all the noise

https://pastebin.com/5U1uSyFT

cantoute
tagDiv Member

no deed for the setTimeout… me dummy… the debounce will async your call 🙂

debounce(
tdbSearch.do_ajax_call(a),
250
);

and the old debounce function or adding underscore
it gets messy to take bits of the more recent _ versions…

  • This reply was modified 6 years by cantoute.
cantoute
tagDiv Member

perhaps on this https://pastebin.com/k0PRwzzC it’s more readable… but not much more :-/ sorry

cantoute
tagDiv Member

Hi Calin,

I was very busy with migrating that 140k pages site, so I didn’t take the time to look into this until now.

So I just prettified the script_for_front.js and had a quick look and the fix seams real easy.

somewhere around line 350 I see this


a.jqueryObj.find(".tdb-head-search-form-input").keydown(function (b)
{
if (b.which && 39 === b.which || b.keyCode && 39 === b.keyCode || b.which && 37 === b.which || b.keyCode && 37 === b.keyCode) tdbSearch.set_input_focus(a);
else
{
if (b.which && 13 === b.which || b.keyCode && 13 === b.keyCode) return b =
a.jqueryObj.find(".tdb-aj-cur-element"), 0 < b.length ? window.location = b.find(".entry-title a").attr("href") : jQuery(this).parent().parent().submit(), !1;
if (b.which && 40 === b.which || b.keyCode && 40 === b.keyCode) return tdbSearch.move_prompt_down(a), !1;
if (b.which && 38 === b.which || b.keyCode && 38 === b.keyCode) return tdbSearch.move_prompt_up(a), !1;
(b.which && 8 === b.which || b.keyCode && 8 === b.keyCode) && 1 === jQuery(this).val().length && a.jqueryObj.find(".tdb-aj-search").empty();
tdbSearch.set_input_focus(a);
setTimeout(function ()
{
tdbSearch.do_ajax_call(a)
},
100);
return !0
}
});

looking just on the last few lines

replacing this

setTimeout(function ()
{
tdbSearch.do_ajax_call(a)
},
100);

by that

debounce(
setTimeout(function () {
tdbSearch.do_ajax_call(a)
}, 0),
250
);

first you would need this https://davidwalsh.name/javascript-debounce-function
actually coming from an old version of underscore (it works!)

function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};

this is the actual up to date function on https://github.com/jashkenas/underscore/blob/master/underscore.js
but perhaps underscore can be useful to have in such a project

I see here that _.debounce requires _.delay who needs restArguments
this could be the “light” way that does the trick too

_ = _ || {};

_.debounce = function(func, wait, immediate) {
var timeout, result;

var later = function(context, args) {
timeout = null;
if (args) result = func.apply(context, args);
};

var debounced = restArguments(function(args) {
if (timeout) clearTimeout(timeout);
if (immediate) {
var callNow = !timeout;
timeout = setTimeout(later, wait);
if (callNow) result = func.apply(this, args);
} else {
timeout = _.delay(later, wait, this, args);
}

return result;
});

debounced.cancel = function() {
clearTimeout(timeout);
timeout = null;
};

return debounced;
};

_.delay = restArguments(function(func, wait, args) {
return setTimeout(function() {
return func.apply(null, args);
}, wait);
});

// Some functions take a variable number of arguments, or a few expected
// arguments at the beginning and then a variable number of values to operate
// on. This helper accumulates all remaining arguments past the function’s
// argument length (or an explicit
startIndex), into an array that becomes
// the last argument. Similar to ES6’s "rest parameter".
var restArguments = function(func, startIndex) {
startIndex = startIndex == null ? func.length - 1 : +startIndex;
return function() {
var length = Math.max(arguments.length - startIndex, 0),
rest = Array(length),
index = 0;
for (; index < length; index++) {
rest[index] = arguments[index + startIndex];
}
switch (startIndex) {
case 0: return func.call(this, rest);
case 1: return func.call(this, arguments[0], rest);
case 2: return func.call(this, arguments[0], arguments[1], rest);
}
var args = Array(startIndex + 1);
for (index = 0; index < startIndex; index++) {
args[index] = arguments[index];
}
args[startIndex] = rest;
return func.apply(this, args);
};
};

Perhaps you all ready have underscore? but didn’t spot it in that js

… it’s got nice goodies and comes handy 🙂 (17.6 KB not so bad ?)

hope this comes helpful, have a nice day.

oups editing code here is dangerous ö

  • This reply was modified 6 years by cantoute. Reason: forgot restArguments
  • This reply was modified 6 years by cantoute. Reason: forgot restArguments
cantoute
tagDiv Member

those url will not show in google console as they will be filtered out… but doesn’t mean google crawler isn’t hunting for them !!!

edit:
for now a rewrite rule lets google crawler get 301 fast… so this is under control

  • This reply was modified 6 years by cantoute.
cantoute
tagDiv Member

Hi,

For now I’ve solved the issue using a rewrite regex redirect rule taking much of the load off

But coming to my mind something I was thinking about… do you think it’s possible to imagine that this json data could come from an get call (from api ?)
That would take it out of the source but there is event a better benefit that could be made of it: it could then be possible to cache the menu separately… making it possible to cache post pages much longer and still having an up to date megamenu with the latest news… just one cache updated updates the menu of the entire site.
just a thought…

thanks for your attention

all the best

cantoute
tagDiv Member

Hi,

I now have google hitting me 50k /day on this type of urls

https://www.welovetennis.fr/us-open/https :/www.welovetennis.fr/atp/atp-zhuhai”

Would be nice if had a look at the source of the page

https://www.welovetennis.fr/us-open/

and tell me if this does come from your theme or is it I should look elswere

To me it looks like I didn’t pick the right choice for the header (I based myself on cloud template model 3) and I would be better off using the “builtin” headers

I’m considering switching to Style 5

would that take all this json/js out of the way ?

to me it seems i’ll stay with the problem

the problem is to have href= or src= anywhere in the page (even in js comments it gets picked up) as the crawler scan the text without analyzing it’s structure to hunt for url.
Same happens with anything having //some.form/of/url

Now I have google crawling like crazy 100k pages / day on things we don’t want… getting really hard on the server… and we’ve got better things to ask google crawler to look for…

I have no issue giving you an access if that could help. But perhaps first if you could confirm that it’s the theme and no other plugin would be helpful.

Thanks

suggestions
“brake” anything like src= href= into ‘hr’ + ‘ef’ + ‘=’
or use a global var $hf=’href=’ $sc=’src=’ $ht=’http://&#8217;

or easy just all encode base64…

this can limit the problem at low cost (and won’t solve it completely) is the <![CDATA[

<script>
//<![CDATA[

<div class=\”td-module-image\”>\r\n <div class=\”td-module-thumb\”>edit<\/a><img width=\”218\” height=\”150\” class=\”entry-thumb\” src=\”https:\/\/www2.welovetennis.fr\/wp-content\/uploads\/2019\/09\/Tsitsipas1959-218×150.jpg\” srcset=\”https:\/\/www2.welovetennis.fr\/wp-content\/uploads\/2019\/09\/Tsitsipas1959-218×150.jpg 218w, https:\/\/www2.we


// ]]>
</script>

cantoute
tagDiv Member

It’s because our users seem to love the search function that I’m going to need this badly… happy to help if possible, because the debounce stuff really are 4 dummy lines to add and they really make a difference on usability and server load.

It’ll make search display much faster then calling on every keypress.

With 140k posts and over 50k daily users… it’s really to be hard on server

Thanks

cantoute
tagDiv Member

Hi,

Yes I use a template from Cloud and I believe I’ve got something wrong on my header as it adds almost 1M of html when I compare http://www.welovetennis.fr and www2.welovetennis.fr for adding just 2 logos… I must have something in there. I’ll just recreate a header from scratch (I had based myself on Template 3 header of Cloud lib, I’ll try starting from blank template this time)

I didn’t see them in search console… yet…
But I could see yahoo, bing and google crawling them. And that yes is not good.
On a 150k pages website this is not helping us (and having wget doing the same is really not a good sign)

This is how I wasted a few hours.

I added this function in prod then put a tail -f on logs to check all was good
Then I spotted those broken url and thought my function was somehow responsable.

Then been hunting for couple hours checking all links. seeing wget -r was doing the same as the crawlers convinced me of investigating further.


// adapting ponctuation for french language
function filter_the_title_fix_ponctuation( $the_title, 5 ) {
//    $the_title = html_entity_decode($the_title);
//    $nbsp = html_entity_decode(" ");
    $thinsp = html_entity_decode(" ");
    $the_title = preg_replace('/ +([\?\!\:])/', $thinsp.'$1', $the_title);
    return $the_title;
}

Thanks for your help

PS
by the was, perhaps you guy could really benefit from using a private stackexchange … this forum isn’t very helpful when trying to find already answer questions…

  • This reply was modified 6 years by cantoute.
cantoute
tagDiv Member

Hi,

No. We just want featured video function to fetch a thumb for the links to the post.

We found a trick, is to first save the post with format video as draft and having the “featured video” field set.
This fetches the featured image, then we clear the “featured video” field before publish. This way it comes out the best for us: a thumb on link to the post and no featured image on the post single page.

Is it possible that the function to fetch featured video thumb would work with tweeter videos ?

That would be nice for us.

Have a nice day

  • This reply was modified 6 years by cantoute.
cantoute
tagDiv Member

but then we lose the feature of having the image from video url ?

cantoute
tagDiv Member

finally making some progress
https://pasteboard.co/IxE7kWU.png

but seems putting zone background transparent isn’t enough… should i got for a custom css ? or is there setting i missed

thanks

cantoute
tagDiv Member

seems the problem is with editing the header when on a page…
or just my browser bugging… sorry for the noise

  • This reply was modified 6 years by cantoute.
cantoute
tagDiv Member

to be more precise, i’de like to reduce the white padding on main colomn

I’de want to reduce width of main content of 20px and the left/right padding of rows of 10px

https://pasteboard.co/IxDlH68.png

thanks

cantoute
tagDiv Member

perhaps having a quick look here you could advise me better

https://www.welovetennis.fr/

I don’t seem to find how to set header background transparent ( the megabanner is part of the header based on Header Template 3 )

Thanks again 🙂

  • This reply was modified 6 years by cantoute.
Viewing 25 posts - 1 through 25 (of 25 total)