href links to old fire version on the server - file

I have a href link which points to a file on the server but the problem is that it sometimes links to an older version of the file. To be able to access the up-to-date version, i need to clear browsing history/cache. I have tried to clear cache with php, but it doesn't help. Any idea why this is happening, and how to get rid of this problem?

You can add a param to link and force the file download.
link

Multiple ways based on scenarios
Apache Caching directives - If you are the server admin you could use apache's mod_cache to manage caching for specific file(types)
Pass the correct HTML header to the browser directing it not to cache it(its its HTML, PHP etc file where you can control the headers of the request)
Pass a randomly generated number in the end of the url like - url-to-file?1234. where 1234 is a randomly generated number(you could use timestamp also instead of the random number)

Related

ReactJS + Express Cache Busting issue

I'm trying to avoid cache busting by setting version numbers in the index.html file name (index.hash.html) generated with html-webpack-plugin. However, I'm unable to get the browser to grab the new file from the server because the old index.html file is still cached for X amount of time.
I could clear cache to hit the server again, or change the cache-control header but this doesn't really work well for users that already have the file cached since it seems they won't see the changes to cache-control anyway. I'm looking for the correct solution and can't seem to find one for this issue.
Any suggestions?
I'm no expert on this, but we're using no hashing for index.html. This means the TTL for it is zero.
On the other hand, all other assets ( js, css , svg ... ) have hashes defined and are cached. Our Service worker on the client checks for newer versions and serve them accordingly.
Hope this helps!

Load Testing Drupal by JMeter

I want to load test DRUPAL by JMeter, but when I run my test plan (it is about updating cart in drupal commerce) it gives me this error:"The form has become outdated. Copy any unsaved work in the form below and then reload this page."
I think the value of form-token is invalid. I use regular expressin for form-token with this regular expression: name="form_token" value="(.+?)".it still does not update cart
How can I solve this problem?
There could be a lot of different reasons for this, most probably:
Missing HTTP Cookie Manager
Missing or improperly working correlation
The solution is comparing the request, which is being generated by JMeter with the request, coming from the real browser - they need to be identical (apart from dynamic bits like cookies or this form_param).
In JMeter you can use View Results Tree listener to check request and response details, variables and cookie values, etc.
In browser you should have developer tools option which allows inspecting the same

What is the best way to update an angular application?

Our team is constantly working on an angular application, and every week or 2 we update it with new features or correct some bugs that came out.
We are using a C# backend with webservices.
QUESTION: When we update the application on the server, we sometimes (this doesn't happen all the time) get the problem that user is still seeing the old HTML and functionalities. What is the way to solve this?
I didn't find this on google, maybe I'm not looking for the right terms,
any help is appreciated.
Users have to clear their cache to get the new version of the application.
What you are seeing are cached copies of the JS files (possibly HTML partials too).
When the browser parses the HTML page, it makes the request for getting the JS resource and looks at various information before deciding to retrieve either the cached copy (if any) or whether to query the server again.
You can find some extra details on the Google fundamentals on HTTP caching
A solution I have been adopting myself is to set the cache headers to cache the file for a very long period, and then use tools in the build to version the file either on the filename or with a request parameter.
I have used grunt-cache-breaker and found it to serve well for this purpose. I know there is a gulp equivalent too
The most common way to make sure cached versions of your javascript aren't used is adding the version as a parameter in the reference to the script like so:
<script src="/app.js?v=v1.0"></script>

Is there anything wrong with using html files without the ".html" extension?

I was wondering if there is anything wrong with using html and php files without extensions.
For example, if I was to upload a file with an extension, I would get to by using a URL like this:
http://yoursite.com/randompage.html
If I used a file without an extension, I would use a URL like this:
http://yoursite.com/randompage
I know that this can't be the preferred method because it leaves the file without a way to be identified, but is there anything that would stop the site from working properly?
What you want to do is done with url-rewriting .
Basically, you will add a rewrite rule to your web server, so when he receives a request for url yoursite.com/randompage he will change it to yoursite.com/randompage.html. You will find a lot of examples on the web if you google for "mod_rewrite examples" or "url rewrite examples".
Document types are sent from the webserver in http headers, so it is perfectly possible to do what you are asking.
For instance when using Apache, to tell it that any file with no extension is html, in the 'conf' file you can say:
DefaultType text/html
More details at Apache The Definitive Guide
This point to concrete document (randompage.html in this case):
http://yoursite.com/randompage.html
This point to default document in directory:
http://yoursite.com/randompage/
Default document is set in you webserver. This could be for example: index.html, default.html, index.php, default.apsx,...

how do you customize url?

www.example.ca/article/563/
I see the above link in a dynamic site. I am working on the site, and there is no folder called 'article' and obviously '563' is dynamically generated as well. I found out I had to edit the article.php page which is located in the root folder to make the changes I wanted, but my question is, how do I make urls appear different from what the actual file location is on the server.
This is commonly called "URL Rewriting". It can be done with appropriate configuration of your webserver, for example Apache's mod_rewrite provides a way to modify incoming URL requests, dynamically, based on regular expression rules.

Resources