Being trivial bundles can be checked on linear equivalent divisors? Let $X$ be a nice (for example, smooth and projective) variety, and let $D_1 \sim D_2$ be two linearly equivalent (smooth and effective) divisors. I would like to know if the following is true:

Let $\mathcal L$ be a line bundle on $X$. Then, $\mathcal L|_{D_1}\simeq \mathcal O_{D_1}$ if and only if $\mathcal L|_{D_2}\simeq \mathcal O_{D_2}$.

If $D_i$ is very ample, this will be true at least for ${\rm dim}(X)$ large, as $\mathcal L$ has to be trivial. If $\mathcal L= \mathcal O(D)$ with $D$ effective, this is also trivially to be true. However, I don't know how to approach this for more general cases.
Moreover, if this is true, I also would like to know if this holds for vector bundles as well, i.e.

Let $\mathcal E$ be a vector bundle on $X$. Then, $\mathcal E|_{D_1}\simeq \mathcal O_{D_1}^{\oplus n}$ if and only if $\mathcal E|_{D_2}\simeq \mathcal O_{D_2}^{\oplus n}$.

Thanks in advance!

Edit:  Now I tend to believe this is false (even for line bundles), and it would be helpful to know a counterexample.
 A: I suggest you take a look at Fulton's book "Intersection theory", since this is actually what you are doing.
The line bundle case is treated early on in the book (this is chapter 2 and the first chapter is quite short). The requirements are that $X$ is of finite type over a field. I will try to give an overview of the possible response.
The line bundle $\mathcal{L}$ represents itself a (pseudo) divisor $V$, and restricting $\mathcal{L}$ to the divisors $D_i$ represents the intersection of $V$ and $D_i$.
The result $V \cdot [D_i]$ is a $n-2$ cycle on $D_i$.
There is then a result, stating that these two intersections are equivalent as cycles on $X$ (paragraph 2.5, chapter 2).
Therefore, one gets a "first chern class morphism"
\begin{equation}
c_1(\mathcal{L})\cap - : A_k(X)\rightarrow A_{k-1}(X)
\end{equation}
Where $A_k$ denotes the cycles modulo rational equivalence.
So this far, we know that $c_1(\mathcal{L})\cap D_1 = 0 \Leftrightarrow c_1(\mathcal{L})\cap D_2=0$.
If the divisors $D_i$ are integral, this is equivalent to the fact that $\mathcal{L}_{|D_i}$ is trivial, due to the equivalence between isomorphism classes of line bundles and Cartier divisors
Edit : this statement is false: as pointed out by Cybre, $A_k(D)\rightarrow A_{k+1}(X)$ need not be injective...
The vector bundle case requires more work on intersection theory and chern classes, and I am not sure under which hypothesis your question could be true. The problem I see, is that the Chern classes do not characterize a vector bundle, so the fact that a given vector bundle has chern class $c(E)=1$ does not guarantee that it is trivial.
A: If you don't mind $D_i$ reducible, here is an example.
Let $C$ be an elliptic curve and $C'=\operatorname{Pic}^0 C$, the line bundles of dgree zero on $C$. So, a point $P\in C'$ will correspond to a line bundle of degree zero on $C$, which I will still call $P$. Let $L$ be the Poincare line bundle on $X=C\times C'$, so $L$ restricted to $C\times{P}$ is just $P$. Let $P\in C'$ be a 2-torsion point and let $D_1=C\times{0}+C\times{P}$. Then, $L^2_{|D_1}=\mathcal{O}_{D_1}$. Clearly, $D_1\sim D_2$, where $D_2=C\times{A}+C\times{B}$, where $A$ (and $B$) is not 2-torsion, since a degree 2 divisor on $C'$ is basepoint free. Then, $L^2_{|D_2}$ is not the trivial line bundle.
