How to Leverage Browser Caching using .htaccess ? (Google Maps api) - .htaccess

So I have tested my page via Googles Page Insights
And it is currently telling me to:
Leverage browser caching for the following cacheable resources:
http://maps.google.com/maps/api/js?sensor=false&language=en (30
minutes)
Its rather ironic as its a google resource from a google server But
Its always good to know how to do things I've tried to read about how to do this on a link google provided on the test page however it didn't really give an example of how to cache this external resource I've tried reading as much as I can and adding bits into my htaccess file but nothing seems to work.
So I guess my question firstly is, is it even possible via the .htaccess file to cache this resouce?
And if so how what code would I need to put in there to get it to cache the resource?
Thanks you In advance for any help.

You can't control the caching of resources served from third party. htaccess is to control caching for resources served out of your own boxes.

Related

Leveraging browser cache in boilerplate

I've used a boilerplate to create a website and I've tested it on https://testmysite.thinkwithgoogle.com/ and it said I have to leverage my browser cache. After doing some research, it says I have to add this tweak in .htaccess. The issue is that this tweak already exist in boilerplate .htaccess so I'm not really sure why the speed checker said I should be leveraging my browser cache?
Any insights why it gives this error?
Update: I've tested it on gtmetrix, it says I have to leverage browser cache of bunch of img, js, and css files. I've checked .htaccess files and there the expires tag of all the mentioned above files. Still no clue why it keep giving that note?
After doing extensive research, I found that git hub web pages don't allow for server configuration, so using .htaccess wouldn't leverage my browser cache. Hoping that github would solve this issue.

Fastly CDN - do not cache specific sections of a page

I am reading Fastly's guides on how to cache pages or using conditions to not cache specific pages. The site I'm working on has some dynamic elements present on all pages of the site which I need to not be cached.
The Fastly guides mention passing specific HTTP headers or using conditions to cache pages and this makes sense for full pages. However, I can't find a clear answer on how to tell the system to not cache parts of a given page while still caching the rest of the page.
Anyone got an example of how I would do this, ideally using IIS / C#?

How to lock website download?

everyone.
I need to lock website for downloading via some windows tools and wget.
The site consists of js, html and php files.
I googled about security resource sharing, but it did not helpful for me.
Thank you.
As long as at the same time you need to have your website online available for everybody, this is not possible. If someone visits your site, the browser needs to access all files, in other words download them. You might be able to apply a few hacks to make it more difficult, but you can not prevent it completely.
If you want to restrict it to a defined audience, you can implement a login using for example HTTP Auth. How this can be achieved depends on your hosting. It might be doable using an .htaccess file in your web root or maybe through the admin interface of your hoster.
Your PHP file should be safe by the way, the above said applies to the public parts of your site (HTML/CSS/JavaScript/Images/...).

Writing a htaccess file - RewriteBase?

Right I'll try and explain my situation as thoroughly as possible while also keeping it brief...
I'm just starting out as a web designer/developer, so I bought the unlimited hosting package with 123-reg. I set up a couple of websites, my main domain being designedbyross.co.uk. I have learnt how to map other domains to a folder within this directory. At the minute, one of my domains, scene63.com is mapped to designedbyross.co.uk/blog63 which is working fine for the home page. However when clicking on another link on scene63.com for example page 2, the URL changes to designedbyross.co.uk/blog63/page2...
I have been advised from someone at 123-reg that I need to write a .htaccess file and use the RewriteBase directive (whatever that is?!) I have looked on a few websites to try and help me understand this, including http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html however it all isn't making much sense at the moment.
Finally, scene63.com is a wordpress site, whether that makes any difference to how the htaccess file is structured I'm not sure...
Any help will be REALLY appreciated - Thanks.
I run my personal public website on Webfusion, which is another branded service offering by the same company on the same infrastructure, and my blog contains a bunch of articles (tagged Webfusion) on how to do this. You really need to do some reading and research -- the Apache docs, articles and HowTos like mine -- to help you get started and then come back with specific Qs, plus the supporting info that we need to answer them.
It sounds like you are using a 123 redirector service, or equivalent for scene63.com which hides the redirection in an iframe. The issue here is that if the links on your site use site-relative links then because the URI has been redirected to http://designedbyross.co.uk/blog6/... then any new pages will be homed in designedbyross.co.uk. (I had the same problem with my wife's business site which mapped the same way to one of my subdirectories).
What you need to do is to configure the blog so that its site base is http://scene63.com/ and to force explicit site-based links so that any hrefs in the pages are of the form http://scene63.com/page2, etc. How you do this depends on the blog engine, but most support this as an option.
It turned out to be a 123-reg problem at the time not correctly applying changes to the DNS.

How to Bypass Output Cache in SharePoint 2007 Publishing Internet site

We're building a mobile-friendly site to work in tandem with our client's MOSS 2007 internet site. We need to be able to redirect users who hit the home page and are using a mobile device.
Our original intention was to add a custom control to the home page page layout that would detect the current user's device and redirect to the mobile site accordingly. We quickly realised that this would not work as we are using the Output Caching functionality provided by SharePoint/Asp.Net. This means that the detection code will only run for the first visitor to the home page until the cache expires.
Our next idea was to build a custom HTTP Module and process the detection there. However, we are finding that the Output Caching is not allowing that either. If the cache is set while a mobile device is visiting all browsers are subsequently redirected to the mobile site (until the cache expires).
If we turn off output caching it works just fine - but we cannot turn output caching off, especically for the home page. We did investigate Substitution (Donut) Caching but this is not working due to the fact we are filtering the Asp.Net response within another HTTP Module that tidies up the rendered HTML for XHTML compatiblity reasons. I've also experimented with the output cache profile by setting it to vary-by-header property to "User-Agent" but I am getting mixed results and am also concerned at the memory implications of caching multipel versions of pages (we already have memory issues now and then).
It's possible we could run the redirection code in JavaScript but then we risk not detecting a lot of devices that don't have JavaScript enabled. This is a government website so the usage of JavaScript has to abide by accessibility guidelines.
Does anyone have any other ideas as to how we can solve this issue. Has anyone done this before? Perhaps in a different way?
Hope you can help, thanks.
p.s. I have also asked this question on SharePoint.SE but wanted to get as many eyes on this as possible.
I would suggest you to try ISAPI filters
I've actually solved this one I think. I've pretty much followed this article here - http://msdn.microsoft.com/en-us/library/ms550239.aspx. We have updated the code in that article to build a cache key based on whether the current page is the home page, whether the current user is using a mobile device and whether or not a cookie exists forcing the user to the full site. I will probably write this up as a blog post. When I do I will update this answer providing a link.

Resources