{"id":752,"date":"2021-12-09T12:30:21","date_gmt":"2021-12-09T15:30:21","guid":{"rendered":"https:\/\/blog.galsoft.duckdns.org\/?p=752"},"modified":"2022-06-08T16:22:15","modified_gmt":"2022-06-08T19:22:15","slug":"forzar-omision-de-cache","status":"publish","type":"post","link":"https:\/\/blog.galsoft.com.ar\/?p=752","title":{"rendered":"Forzar &#8220;omisi\u00f3n&#8221; de cache"},"content":{"rendered":"<p>Usando unas simples <strong>etiquetas HTML<\/strong> podemos forzar para que el navegador del visitante no tenga en cuenta el cache del navegador, esto tambi\u00e9n es \u00fatil para<strong> cuando tenemos un sitio web que se actualiza mucho<\/strong> y el <strong>cache del navegador<\/strong> nos dificulta el proceso.<\/p>\n<p>Todo lo que debemos hacer es introducir una de las siguientes <strong>etiquetas en el HEAD<\/strong>, es decir, entre la etiqueta <strong><\/strong> y la etiqueta <strong><\/strong>:<\/p>\n<p>HTML:<\/p>\n<pre class=\"wp-block-code\"><code>&lt;head&gt;\n    &lt;meta http-equiv=&quot;Expires&quot; content=&quot;0&quot;&gt;\n    &lt;meta http-equiv=&quot;Last-Modified&quot; content=&quot;0&quot;&gt;\n    &lt;meta http-equiv=&quot;Cache-Control&quot; content=&quot;no-cache, mustrevalidate&quot;&gt;\n    &lt;meta http-equiv=&quot;Pragma&quot; content=&quot;no-cache&quot;&gt;\n&lt;\/head&gt;<\/code><\/pre>\n<p>Con esto, el navegador del cliente <strong>ya no tendr\u00e1 en cuenta el cache<\/strong> que ha guardado anteriormente.<\/p>\n<p>En <strong>Wordpress<\/strong>, para a\u00f1adir estar etiquetas en el <strong>HEAD<\/strong> debemos <strong>editar la plantilla o theme<\/strong>, concretamente debemos editar el <strong>archivo \u201cheader.php\u201d<\/strong> donde se encuentran las etiquetas <strong><\/strong> y <strong><\/strong> entre las que debemos meter una de las l\u00edneas anteriores.<\/p>\n<p>Tambi\u00e9n es posible<strong> forzar a una aplicaci\u00f3n desarrollada en PHP<\/strong> para que no guarde cache de navegador, para ello debemos utilizar el siguiente c\u00f3digo en el <strong>archivo PHP<\/strong> cargado:<\/p>\n<p>PHP:<\/p>\n<pre class=\"wp-block-code\"><code>&lt;?php\nheader(&quot;Cache-Control: no-cache, must-revalidate&quot;); \/\/ HTTP\/1.1\nheader(&quot;Expires: Sat, 1 Jul 2000 05:00:00 GMT&quot;); \/\/ Fecha en el pasado\n?&gt;<\/code><\/pre>\n<p>Con esto<strong> nos aseguraremos de que el cache se resetee en todos los navegadores web y proxy http<\/strong> que visiten el sitio web.<\/p>\n<p>Tambi\u00e9n puedes <a href=\"https:\/\/blog.galsoft.com.ar\/?p=907\">limpiar la cache de laravel<\/a> <\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Usando unas simples etiquetas HTML podemos forzar para que el navegador del visitante no tenga en cuenta el cache del navegador, esto tambi\u00e9n es \u00fatil para cuando tenemos un sitio web que se actualiza mucho y el cache del navegador nos dificulta el proceso. Todo lo que debemos hacer es introducir una de las siguientes [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[2,10],"tags":[],"class_list":["post-752","post","type-post","status-publish","format-standard","hentry","category-php","category-programacion","entry"],"_links":{"self":[{"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/posts\/752","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=752"}],"version-history":[{"count":5,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/posts\/752\/revisions"}],"predecessor-version":[{"id":910,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/posts\/752\/revisions\/910"}],"wp:attachment":[{"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}